… | |
… | |
236 | $self->{command_widget} ||= |
236 | $self->{command_widget} ||= |
237 | new CFClient::MapWidget::Command:: |
237 | new CFClient::MapWidget::Command:: |
238 | command => $self->{command}, |
238 | command => $self->{command}, |
239 | can_focus => 1, |
239 | can_focus => 1, |
240 | connect_execute => sub { |
240 | connect_execute => sub { |
|
|
241 | # todo: support callback instead of user_send |
241 | $::CONN->user_send ($_[1]); |
242 | $::CONN->user_send ($_[1][1]); |
242 | }, |
243 | }, |
243 | connect_close => sub { |
244 | connect_close => sub { |
244 | (delete $self->{command_widget})->hide; |
245 | (delete $self->{command_widget})->hide; |
245 | $self->focus_in; |
246 | $self->focus_in; |
246 | }, |
247 | }, |
247 | ; |
248 | ; |
248 | $self->{command_widget}->key_down ($ev); |
249 | $self->{command_widget}->key_down ($ev); |
|
|
250 | return unless $self->{command_widget}; |
249 | $self->{command_widget}->show; |
251 | $self->{command_widget}->show; |
250 | $self->{command_widget}->focus_in; |
252 | $self->{command_widget}->focus_in; |
251 | } |
253 | } |
252 | } |
254 | } |
253 | |
255 | |
… | |
… | |
264 | $::CONN->user_send ("run_stop"); |
266 | $::CONN->user_send ("run_stop"); |
265 | } |
267 | } |
266 | } |
268 | } |
267 | |
269 | |
268 | sub add_command { |
270 | sub add_command { |
269 | my ($self, $command, $widget, $cb) = @_; |
271 | my ($self, $command, $tooltip, $widget, $cb) = @_; |
270 | |
272 | |
271 | (my $abbrev = $command) =~ s/(\S)[^[:space:]_]*[[:space:]_]+/$1/g; |
273 | (my $abbrev = $command) =~ s/(\S)[^[:space:]_]*[[:space:]_]+/$1/g; |
272 | |
274 | |
273 | push @{$self->{command}}, [$abbrev, $command]; |
275 | push @{$self->{command}}, [$abbrev, $command, $tooltip, $widget, $cb]; |
274 | #warn "$command|$abbrev|$widget\n";#d# |
|
|
275 | } |
276 | } |
276 | |
277 | |
277 | package CFClient::MapWidget::Command; |
278 | package CFClient::MapWidget::Command; |
278 | |
279 | |
279 | use strict; |
280 | use strict; |
… | |
… | |
287 | |
288 | |
288 | my $self = $class->SUPER::new ( |
289 | my $self = $class->SUPER::new ( |
289 | @_, |
290 | @_, |
290 | children => [map |
291 | children => [map |
291 | CFClient::UI::Label->new ( |
292 | CFClient::UI::Label->new ( |
292 | can_hover => 1, |
293 | can_hover => 1, |
|
|
294 | can_events => 1, |
293 | fontsize => $_, |
295 | fontsize => $_, |
294 | ), 1, 1, 0.8, 0.8, 0.8, 0.8, 0.8 |
296 | ), 1, 1, 0.8, 0.8, 0.8, 0.8, 0.8 |
295 | ], |
297 | ], |
296 | ); |
298 | ); |
297 | |
299 | |
298 | $self |
300 | $self |
… | |
… | |
326 | |
328 | |
327 | $self->{children}[0]->set_text ("$self->{search}_"); |
329 | $self->{children}[0]->set_text ("$self->{search}_"); |
328 | |
330 | |
329 | for (0..5) { |
331 | for (0..5) { |
330 | $self->{children}[$_ + 1]->set_text ($found[$_] ? "$found[$_][0] ($found[$_][1][1])" : ""); |
332 | $self->{children}[$_ + 1]->set_text ($found[$_] ? "$found[$_][0] ($found[$_][1][1])" : ""); |
|
|
333 | $self->{children}[$_ + 1]{tooltip} = ($found[$_] ? $found[$_][1][2] : ""); |
331 | } |
334 | } |
332 | |
335 | |
333 | $self->{select} = $found[0][1][1] |
336 | $self->{select} = $found[0][1] |
334 | if @found; |
337 | if @found; |
335 | |
338 | |
336 | if (@found > 6) { |
339 | if (@found > 6) { |
337 | $self->{children}[6]->set_text ("..."); |
340 | $self->{children}[6]->set_text ("..."); |
338 | } |
341 | } |