@@ -84,13 +84,16 @@ def __init__(
84
84
description : str ,
85
85
action : str ,
86
86
disabled : bool = False ,
87
+ tooltip : str = "" ,
87
88
) -> None :
88
89
self .key = key
89
90
self .key_display = key_display
90
91
self .description = description
91
92
self .action = action
92
93
self ._disabled = disabled
93
94
super ().__init__ (classes = "-disabled" if disabled else "" )
95
+ if tooltip :
96
+ self .tooltip = tooltip
94
97
95
98
def render (self ) -> Text :
96
99
key_style = self .get_component_rich_style ("footer-key--key" )
@@ -160,24 +163,25 @@ def compose(self) -> ComposeResult:
160
163
if not self ._bindings_ready :
161
164
return
162
165
bindings = [
163
- (binding , enabled )
164
- for (_ , binding , enabled ) in self .screen .active_bindings .values ()
166
+ (binding , enabled , tooltip )
167
+ for (_ , binding , enabled , tooltip ) in self .screen .active_bindings .values ()
165
168
if binding .show
166
169
]
167
- action_to_bindings : defaultdict [str , list [tuple [Binding , bool ]]]
170
+ action_to_bindings : defaultdict [str , list [tuple [Binding , bool , str ]]]
168
171
action_to_bindings = defaultdict (list )
169
- for binding , enabled in bindings :
170
- action_to_bindings [binding .action ].append ((binding , enabled ))
172
+ for binding , enabled , tooltip in bindings :
173
+ action_to_bindings [binding .action ].append ((binding , enabled , tooltip ))
171
174
172
175
self .styles .grid_size_columns = len (action_to_bindings )
173
176
for multi_bindings in action_to_bindings .values ():
174
- binding , enabled = multi_bindings [0 ]
177
+ binding , enabled , tooltip = multi_bindings [0 ]
175
178
yield FooterKey (
176
179
binding .key ,
177
180
binding .key_display or self .app .get_key_display (binding .key ),
178
181
binding .description ,
179
182
binding .action ,
180
183
disabled = not enabled ,
184
+ tooltip = tooltip ,
181
185
).data_bind (
182
186
Footer .upper_case_keys ,
183
187
Footer .ctrl_to_caret ,
0 commit comments