gui icon indicating copy to clipboard operation
gui copied to clipboard

Tooltips for menus and buttons

Open lehitoskin opened this issue 10 years ago • 10 comments

It's a common thing to hover over a button in nemo or firefox and a little tooltip will appear describing what the button does. button% doesn't provide this interface and the help-string from menu-item% doesn't to, uh, do much of anything that I can see. If there's a way to do this already, I'd love to hear, otherwise...

Feature request! Tooltip functionality for menu-item% and button% and, like, other things that might plausibly be hovered over.

lehitoskin avatar Sep 17 '15 07:09 lehitoskin

i've started working on it. gtk done.

https://github.com/jkominek/racket-gui/tree/tooltips

jkominek avatar Sep 21 '15 02:09 jkominek

That's magical. Thank you!

lehitoskin avatar Sep 21 '15 06:09 lehitoskin

@jkominek Any update on this? It's been a while and I haven't heard anything...

lehitoskin avatar Jun 03 '16 20:06 lehitoskin

It would be nice to have this working.

Indeed it appears that when hovering on the menu-item% nothing happens, on all 3 platforms:

#lang racket/gui
(define fr (new frame% [label "frame"] [width 200] [height 200]))
(define menu-bar (new menu-bar% [parent fr]))
(define menu (new menu%
                  [parent menu-bar]
                  [label "Help!"]))
(define it1 (new menu-item% [parent menu]
                 [label "item"]
                 [help-string "Help me!"]
                 [callback void]))
(send fr show #t)

Metaxal avatar Jun 14 '20 12:06 Metaxal

Please consider adding the label good first issue so it is findable:

Issues labeled good first issue in in Racket GitHub repositories

spdegabrielle avatar Jun 18 '20 09:06 spdegabrielle

You can use the gui-widget-mixins package to add tool-tips to all controls except menu items (since menu items are not window<%> instances:

tooltips

#lang racket/gui
(require gui-widget-mixins)

(define toplevel (new frame% [label "Hello"] [width 100] [height 100]
                      [border 10] [spacing 10]))

(define button
  (new (tooltip-mixin button%)
       [parent toplevel]
       [label "Push Me"]
       [tooltip "Please Push The Button"]))

(define checkbox
  (new (tooltip-mixin check-box%)
       [parent toplevel]
       [label "Click Me"]
       [tooltip "Please Check the Checkbox"]))

(define choices
  (new (tooltip-mixin choice%)
       [parent toplevel]
       [label "Make Your Selection: "]
       [choices '("First Option" "Second Option" "Third Option")]
       [tooltip "The second option is the best one"]))

(send toplevel show #t)

alex-hhh avatar Jun 27 '20 00:06 alex-hhh

This is very nice @alex-hhh ! Any idea how to make it work for menus?

Metaxal avatar Jun 27 '20 08:06 Metaxal

This works for controls because they implement the window<%> interface, so they can be extended to intercept mouse events. Menus and menu items don't implement this interface, so we cannot intercept the mouse when it overs over a menu to display a tool tip.

Adding tool-tips to menus would require updates to the GUI library and this may be platform specific -- i.e. they would have to be implemented three times: for MacOS, Windows and GTK (Linux).


I should point out that the work in progress mentioned in the previous comment also focuses on GUI controls and not menus. That approach uses the native tooltips (they did it for GTK, MacOS is work in progress, and have not done it for Win32). Still, that approach would not support tooltips on menus, that would be a separate implementation.

alex-hhh avatar Jun 27 '20 23:06 alex-hhh

That's too bad. Thanks for the update!

Metaxal avatar Jun 28 '20 13:06 Metaxal

@alex-hhh It doesn't seem to work on gnome/ubuntu, not sure why.

There's also a very similar tooltip%% mixin in mred-designer (same caveats, for the same reasons), which can be tried with:

#lang racket/gui
(require mred-designer/tooltip)

(define f (new frame% (label "Test")))
(define b (new (tooltip%% button%) (parent f)
               (label "Hello")
               (tooltip-text "Button") ))
(define c (new (tooltip%% check-box%) (parent f)
               (label "Hello")
               (tooltip-text "Check Box") ))
(define r (new (tooltip%% radio-box%) (parent f)
               (label "Hello")
               (choices '("a" "b" "c"))
               (tooltip-text "Radio Box") ))
(send f show #t)

The current delay seems a little long though.

Metaxal avatar Jun 28 '20 14:06 Metaxal