@@ -45,14 +45,16 @@ public sealed class StatusBarColorPaletteWidget : Gtk.DrawingArea
4545
4646 private readonly IChromeService chrome ;
4747 private readonly IPaletteService palette ;
48+ private readonly ISystemService system ;
4849
4950 private RectangleD palette_rect ;
5051 private RectangleD recent_palette_rect ;
5152
52- public StatusBarColorPaletteWidget ( IChromeService chrome , IPaletteService palette )
53+ public StatusBarColorPaletteWidget ( IChromeService chrome , IPaletteService palette , ISystemService system )
5354 {
5455 this . chrome = chrome ;
5556 this . palette = palette ;
57+ this . system = system ;
5658
5759 HasTooltip = true ;
5860 OnQueryTooltip += HandleQueryTooltip ;
@@ -71,13 +73,13 @@ public StatusBarColorPaletteWidget (IChromeService chrome, IPaletteService palet
7173 Gtk . GestureClick click_gesture = Gtk . GestureClick . New ( ) ;
7274 click_gesture . SetButton ( 0 ) ; // Listen for all mouse buttons.
7375 click_gesture . OnReleased += ( _ , e ) => {
74- HandleClick ( new PointD ( e . X , e . Y ) , click_gesture . GetCurrentButton ( ) ) ;
76+ HandleClick ( new PointD ( e . X , e . Y ) , click_gesture . GetCurrentButton ( ) , click_gesture . GetCurrentEventState ( ) ) ;
7577 click_gesture . SetState ( Gtk . EventSequenceState . Claimed ) ;
7678 } ;
7779 AddController ( click_gesture ) ;
7880 }
7981
80- private async void HandleClick ( PointD point , uint button )
82+ private async void HandleClick ( PointD point , uint button , Gdk . ModifierType state )
8183 {
8284 var element = GetElementAtPoint ( point ) ;
8385
@@ -138,11 +140,13 @@ private async void HandleClick (PointD point, uint button)
138140 if ( index < 0 )
139141 break ;
140142
143+ bool isCtrlPressed = state . IsControlPressed ( ) ;
141144 if ( button == GtkExtensions . MOUSE_RIGHT_BUTTON ) {
142145 palette . SecondaryColor = palette . CurrentPalette . Colors [ index ] ;
143- } else if ( button == GtkExtensions . MOUSE_LEFT_BUTTON ) {
146+ } else if ( button == GtkExtensions . MOUSE_LEFT_BUTTON && ! isCtrlPressed ) {
144147 palette . PrimaryColor = palette . CurrentPalette . Colors [ index ] ;
145- } else {
148+ } else if ( button == GtkExtensions . MOUSE_MIDDLE_BUTTON ||
149+ ( button == GtkExtensions . MOUSE_LEFT_BUTTON && isCtrlPressed ) ) {
146150 SingleColor pick = new ( palette . CurrentPalette . Colors [ index ] ) ;
147151 var colors = await GetUserChosenColor (
148152 pick ,
@@ -307,8 +311,12 @@ private bool HandleQueryTooltip (object o, Gtk.Widget.QueryTooltipSignalArgs arg
307311
308312 switch ( GetElementAtPoint ( point ) ) {
309313 case WidgetElement . Palette :
310- if ( PaletteWidget . GetSwatchAtLocation ( palette , point , palette_rect ) >= 0 )
311- text = Translations . GetString ( "Left click to set primary color. Right click to set secondary color. Middle click to choose palette color." ) ;
314+ if ( PaletteWidget . GetSwatchAtLocation ( palette , point , palette_rect ) >= 0 ) {
315+ // Translators: {0} is 'Ctrl', or a platform-specific key such as 'Command' on macOS.
316+ text = Translations . GetString ( "Left click to set primary color. Right click to set secondary color. Middle click or press {0} and left click to choose palette color." ,
317+ system . CtrlLabel ( ) ) ;
318+ }
319+
312320 break ;
313321 case WidgetElement . RecentColorsPalette :
314322 if ( PaletteWidget . GetSwatchAtLocation ( palette , point , recent_palette_rect , true ) >= 0 )
0 commit comments