You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When the application window does not have focus, and I open a context menu by right-clicking the window, the window stays non-focused on Mac.
The context menu still appears, still highlights the options under my mouse, etc. But when I click on an option from the context menu in this state, the context menu disappears without performing the action that it would normally perform. For an action that doesn't display any immediate sign of it working other than the context menu closing, this can fool users into thinking they used the context menu to perform the action, when they didn't.
I can think of 2 reasonable sets of behaviors:
Perform the action and close the context menu.
Give focus without performing the action or closing, allowing the user to click again now that it has focus.
With the current confusing behavior being:
"Silently" fail with no action and close the context menu.
On Windows, right-clicking the window gives focus immediately. To someone not paying attention to which window has focus, this looks most like (1).
Below is a small Context Menu Example showing this behavior. On control-clicking, it gets focus and behaves as expected. But on right-clicking with a mouse, it does not get focus on Mac, and this confusing behavior appears:
use druid::widget::prelude::*;use druid::widget::{Align,Controller,Label};use druid::{AppLauncher,Data,Env,Lens,LocalizedString,Menu,MenuItem,Selector,Widget,WidgetExt,WindowDesc,};constWINDOW_TITLE:LocalizedString<CounterState> = LocalizedString::new("Context Menu Example");#[derive(Clone,Data,Lens)]structCounterState{i:i64,}structCounterController;constCONTEXT_MENU_COUNTER_INCREMENT:Selector = Selector::new("context-menu-counter-increment");constCONTEXT_MENU_COUNTER_DECREMENT:Selector = Selector::new("context-menu-counter-decrement");impl<W:Widget<CounterState>>Controller<CounterState,W>forCounterController{fnevent(&mutself,child:&mutW,ctx:&mutEventCtx,event:&Event,data:&mutCounterState,env:&Env,){match event {Event::MouseUp(event) => {if event.button.is_right() || (event.button.is_left() && event.mods.ctrl()){
ctx.show_context_menu::<CounterState>(Menu::new("Counter").entry(MenuItem::new("Increment").command(CONTEXT_MENU_COUNTER_INCREMENT),).entry(MenuItem::new("Decrement").command(CONTEXT_MENU_COUNTER_DECREMENT),),
event.pos,);}}Event::Command(command) => {if command.is(CONTEXT_MENU_COUNTER_INCREMENT){
data.i += 1;}elseif command.is(CONTEXT_MENU_COUNTER_DECREMENT){
data.i -= 1;}}
_ => {}}// Always pass on the event!
child.event(ctx, event, data, env)}}fnmain(){// describe the main windowlet main_window = WindowDesc::new(build_root_widget()).title(WINDOW_TITLE).window_size((400.0,400.0));// create the initial app statelet initial_state = CounterState{i:0};// start the applicationAppLauncher::with_window(main_window).launch(initial_state).expect("Failed to launch application");}fnbuild_root_widget() -> implWidget<CounterState>{// a label that will determine its text based on the current app data.let label = Label::new(|data:&CounterState,_env:&Env| format!("Counter: {}", data.i));// center the a widget in the available spaceAlign::centered(label).controller(CounterController)}
The text was updated successfully, but these errors were encountered:
When the application window does not have focus, and I open a context menu by right-clicking the window, the window stays non-focused on Mac.
The context menu still appears, still highlights the options under my mouse, etc. But when I click on an option from the context menu in this state, the context menu disappears without performing the action that it would normally perform. For an action that doesn't display any immediate sign of it working other than the context menu closing, this can fool users into thinking they used the context menu to perform the action, when they didn't.
I can think of 2 reasonable sets of behaviors:
With the current confusing behavior being:
On Windows, right-clicking the window gives focus immediately. To someone not paying attention to which window has focus, this looks most like (1).
Below is a small Context Menu Example showing this behavior. On control-clicking, it gets focus and behaves as expected. But on right-clicking with a mouse, it does not get focus on Mac, and this confusing behavior appears:
The text was updated successfully, but these errors were encountered: