… | |
… | |
325 | $prompt = $LAST_QUERY unless length $prompt; |
325 | $prompt = $LAST_QUERY unless length $prompt; |
326 | $LAST_QUERY = $prompt; |
326 | $LAST_QUERY = $prompt; |
327 | |
327 | |
328 | my $dialog = new CFClient::UI::FancyFrame |
328 | my $dialog = new CFClient::UI::FancyFrame |
329 | title => "Query", |
329 | title => "Query", |
330 | child => my $vbox = new CFClient::UI::VBox; |
330 | child => my $vbox = new CFClient::UI::VBox, |
|
|
331 | on_visibility_change => sub { |
|
|
332 | my ($self, $visible) = @_; |
|
|
333 | $self->center if $visible; |
|
|
334 | }, |
|
|
335 | ; |
331 | |
336 | |
332 | $vbox->add (new CFClient::UI::Label |
337 | $vbox->add (new CFClient::UI::Label |
333 | max_w => $::WIDTH * 0.4, |
338 | max_w => $::WIDTH * 0.4, |
334 | ellipsise => 0, |
339 | ellipsise => 0, |
335 | text => $prompt); |
340 | text => $prompt); |
336 | |
341 | |
337 | if ($flags & CS_QUERY_YESNO) { |
342 | if ($flags & CS_QUERY_YESNO) { |
338 | $vbox->add (my $hbox = new CFClient::UI::HBox); |
343 | $vbox->add (my $hbox = new CFClient::UI::HBox); |
339 | $hbox->add (new CFClient::UI::Button |
344 | $hbox->add (new CFClient::UI::Button |
340 | text => "No", |
345 | text => "No", |
341 | connect_activate => sub { |
346 | on_activate => sub { |
342 | $self->send ("reply n"); |
347 | $self->send ("reply n"); |
343 | $dialog->destroy; |
348 | $dialog->destroy; |
344 | $self->{map_widget}->focus_in; |
349 | $self->{map_widget}->focus_in; |
345 | } |
350 | } |
346 | ); |
351 | ); |
347 | $hbox->add (new CFClient::UI::Button |
352 | $hbox->add (new CFClient::UI::Button |
348 | text => "Yes", |
353 | text => "Yes", |
349 | connect_activate => sub { |
354 | on_activate => sub { |
350 | $self->send ("reply y"); |
355 | $self->send ("reply y"); |
351 | $dialog->destroy; |
356 | $dialog->destroy; |
352 | }, |
357 | }, |
353 | ); |
358 | ); |
354 | |
359 | |
355 | $dialog->focus_in; |
360 | $dialog->focus_in; |
356 | |
361 | |
357 | } elsif ($flags & CS_QUERY_SINGLECHAR) { |
362 | } elsif ($flags & CS_QUERY_SINGLECHAR) { |
358 | $dialog->{tooltip} = "Press a key (click on the entry to make sure it has keyboard focus)"; |
363 | $dialog->{tooltip} = "Press a key (click on the entry to make sure it has keyboard focus)"; |
359 | $vbox->add (my $entry = new CFClient::UI::Entry |
364 | $vbox->add (my $entry = new CFClient::UI::Entry |
360 | connect_changed => sub { |
365 | on_changed => sub { |
361 | $self->send ("reply $_[1]"); |
366 | $self->send ("reply $_[1]"); |
362 | $dialog->destroy; |
367 | $dialog->destroy; |
363 | }, |
368 | }, |
364 | ); |
369 | ); |
365 | |
370 | |
… | |
… | |
368 | } else { |
373 | } else { |
369 | $dialog->{tooltip} = "Enter the reply and press return (click on the entry to make sure it has keyboard focus)"; |
374 | $dialog->{tooltip} = "Enter the reply and press return (click on the entry to make sure it has keyboard focus)"; |
370 | |
375 | |
371 | $vbox->add (my $entry = new CFClient::UI::Entry |
376 | $vbox->add (my $entry = new CFClient::UI::Entry |
372 | $flags & CS_QUERY_HIDEINPUT ? (hiddenchar => "*") : (), |
377 | $flags & CS_QUERY_HIDEINPUT ? (hiddenchar => "*") : (), |
373 | connect_activate => sub { |
378 | on_activate => sub { |
374 | $self->send ("reply $_[1]"); |
379 | $self->send ("reply $_[1]"); |
375 | $dialog->destroy; |
380 | $dialog->destroy; |
376 | }, |
381 | }, |
377 | ); |
382 | ); |
378 | |
383 | |
379 | $entry->focus_in; |
384 | $entry->focus_in; |
380 | } |
385 | } |
381 | |
386 | |
382 | $dialog->show_centered; |
387 | $dialog->show; |
383 | } |
388 | } |
384 | |
389 | |
385 | sub drawinfo { |
390 | sub drawinfo { |
386 | my ($self, $color, $text) = @_; |
391 | my ($self, $color, $text) = @_; |
387 | |
392 | |