Skip to content

Latest commit

 

History

History
128 lines (103 loc) · 4.35 KB

File metadata and controls

128 lines (103 loc) · 4.35 KB

UI Interaction Issue Fix

Problem

None of the controls in the UI were responding to mouse or keyboard events.

Root Cause Analysis

The issue was likely caused by one or more of the following:

  1. Central Panel Event Consumption: The central panel was using Sense::click_and_drag() which could potentially consume events meant for other UI elements.

  2. Window Focus/Activation: The window might not have been properly activated or focused on creation.

  3. egui Style Configuration: Default interaction settings might not have been optimal for the UI.

Changes Made

1. Modified Central Panel Sense (src/ui/app.rs:933-940)

Changed from:

let (rect, _response) = ui.allocate_exact_size(
    available_size,
    egui::Sense::click_and_drag()
);

Changed to:

let (rect, response) = ui.allocate_exact_size(
    available_size,
    egui::Sense::hover()
);

Rationale: Sense::hover() is less aggressive about consuming events compared to Sense::click_and_drag(), allowing buttons and other interactive elements to receive their events properly. We're also now capturing the response (even if not currently using it) which is good practice.

2. Added Window Activation (src/main.rs:19-26)

Changed from:

let native_options = eframe::NativeOptions {
    viewport: egui::ViewportBuilder::default()
        .with_title("rCandle - GRBL Controller")
        .with_inner_size([1280.0, 800.0])
        .with_min_inner_size([800.0, 600.0]),
    ..Default::default()
};

Changed to:

let native_options = eframe::NativeOptions {
    viewport: egui::ViewportBuilder::default()
        .with_title("rCandle - GRBL Controller")
        .with_inner_size([1280.0, 800.0])
        .with_min_inner_size([800.0, 600.0])
        .with_active(true)
        .with_visible(true),
    ..Default::default()
};

Rationale: Explicitly requesting the window to be active and visible on creation ensures it has proper focus and can receive input events from the window manager.

3. Configured egui Interaction Style (src/ui/app.rs:52-57)

Added:

// Configure egui style for better interactivity
let mut style = (*cc.egui_ctx.style()).clone();
style.interaction.selectable_labels = true;
cc.egui_ctx.set_style(style);

Rationale: Ensures that egui's interaction system is properly configured with selectable labels enabled, which can improve overall UI responsiveness.

4. Added Debug Logging (src/ui/app.rs:610-620)

Added logging to connection buttons:

if ui.button("Connect").clicked() {
    tracing::info!("Connect button clicked");
    self.status_message = "Connecting...".to_string();
    self.console.info("Connect button clicked".to_string());
}

Rationale: Helps diagnose whether button clicks are being registered, making future debugging easier.

Testing

After these changes:

  1. Build the application: cargo build
  2. Run the application: cargo run
  3. Test interactions:
    • Click buttons in the left control panel
    • Use menu items in the top menu bar
    • Type in the console at the bottom
    • Use keyboard shortcuts (Ctrl+O, Ctrl+S, Ctrl+F)
    • Interact with sliders and other controls

Expected Behavior

All UI controls should now respond to:

  • Mouse clicks
  • Mouse hover (for tooltips and visual feedback)
  • Keyboard input (text fields, shortcuts)
  • Drag operations (sliders, scrollbars)

Additional Notes

  • The central panel's 2D toolpath viewer should still be visible and render correctly
  • The WGPU 3D rendering backend should not interfere with egui's event handling
  • All existing functionality should remain intact

If Issues Persist

If UI controls still don't respond after these changes, check:

  1. Window Manager Focus: Ensure the window actually has focus (click on it)
  2. Input Method: If using remote desktop or virtualization, ensure proper input forwarding
  3. Graphics Drivers: Update graphics drivers, especially for Vulkan/WGPU support
  4. egui Version Compatibility: Current version is 0.27.2 - consider updating if issues persist
  5. Platform-Specific Issues: Check egui-winit issues on GitHub for Linux-specific problems

Related Files

  • src/ui/app.rs - Main UI application logic
  • src/main.rs - Application entry point and window configuration
  • src/ui/widgets.rs - Custom UI widgets (GCodeEditor, Console)

Date

2025-10-05

Version

rCandle v0.1.0