@@ -70,10 +70,20 @@ pub fn zoom_out(ctx: &Context) {
70
70
///
71
71
/// This is meant to be called from within a menu (See [`Ui::menu_button`]).
72
72
pub fn zoom_menu_buttons ( ui : & mut Ui ) {
73
+ fn button ( ctx : & Context , text : & str , shortcut : & KeyboardShortcut ) -> Button < ' static > {
74
+ let btn = Button :: new ( text) ;
75
+ let zoom_with_keyboard = ctx. options ( |o| o. zoom_with_keyboard ) ;
76
+ if zoom_with_keyboard {
77
+ btn. shortcut_text ( ctx. format_shortcut ( shortcut) )
78
+ } else {
79
+ btn
80
+ }
81
+ }
82
+
73
83
if ui
74
84
. add_enabled (
75
85
ui. ctx ( ) . zoom_factor ( ) < MAX_ZOOM_FACTOR ,
76
- Button :: new ( "Zoom In" ) . shortcut_text ( ui. ctx ( ) . format_shortcut ( & kb_shortcuts:: ZOOM_IN ) ) ,
86
+ button ( ui. ctx ( ) , "Zoom In" , & kb_shortcuts:: ZOOM_IN ) ,
77
87
)
78
88
. clicked ( )
79
89
{
@@ -84,8 +94,7 @@ pub fn zoom_menu_buttons(ui: &mut Ui) {
84
94
if ui
85
95
. add_enabled (
86
96
ui. ctx ( ) . zoom_factor ( ) > MIN_ZOOM_FACTOR ,
87
- Button :: new ( "Zoom Out" )
88
- . shortcut_text ( ui. ctx ( ) . format_shortcut ( & kb_shortcuts:: ZOOM_OUT ) ) ,
97
+ button ( ui. ctx ( ) , "Zoom Out" , & kb_shortcuts:: ZOOM_OUT ) ,
89
98
)
90
99
. clicked ( )
91
100
{
@@ -96,8 +105,7 @@ pub fn zoom_menu_buttons(ui: &mut Ui) {
96
105
if ui
97
106
. add_enabled (
98
107
ui. ctx ( ) . zoom_factor ( ) != 1.0 ,
99
- Button :: new ( "Reset Zoom" )
100
- . shortcut_text ( ui. ctx ( ) . format_shortcut ( & kb_shortcuts:: ZOOM_RESET ) ) ,
108
+ button ( ui. ctx ( ) , "Reset Zoom" , & kb_shortcuts:: ZOOM_RESET ) ,
101
109
)
102
110
. clicked ( )
103
111
{
0 commit comments