… | |
… | |
347 | my ($self, $flags, $prompt) = @_; |
347 | my ($self, $flags, $prompt) = @_; |
348 | |
348 | |
349 | $prompt = $LAST_QUERY unless length $prompt; |
349 | $prompt = $LAST_QUERY unless length $prompt; |
350 | $LAST_QUERY = $prompt; |
350 | $LAST_QUERY = $prompt; |
351 | |
351 | |
352 | my $dialog = new CFClient::UI::FancyFrame |
352 | $self->{query}-> ($self, $flags, $prompt); |
353 | x => "center", |
|
|
354 | y => "center", |
|
|
355 | title => "Query", |
|
|
356 | child => my $vbox = new CFClient::UI::VBox, |
|
|
357 | ; |
|
|
358 | |
|
|
359 | $vbox->add (new CFClient::UI::Label |
|
|
360 | max_w => $::WIDTH * 0.4, |
|
|
361 | ellipsise => 0, |
|
|
362 | text => $prompt); |
|
|
363 | |
|
|
364 | if ($flags & CS_QUERY_YESNO) { |
|
|
365 | $vbox->add (my $hbox = new CFClient::UI::HBox); |
|
|
366 | $hbox->add (new CFClient::UI::Button |
|
|
367 | text => "No", |
|
|
368 | on_activate => sub { |
|
|
369 | $self->send ("reply n"); |
|
|
370 | $dialog->destroy; |
|
|
371 | $self->{map_widget}->focus_in; |
|
|
372 | } |
|
|
373 | ); |
|
|
374 | $hbox->add (new CFClient::UI::Button |
|
|
375 | text => "Yes", |
|
|
376 | on_activate => sub { |
|
|
377 | $self->send ("reply y"); |
|
|
378 | $dialog->destroy; |
|
|
379 | }, |
|
|
380 | ); |
|
|
381 | |
|
|
382 | $dialog->focus_in; |
|
|
383 | |
|
|
384 | } elsif ($flags & CS_QUERY_SINGLECHAR) { |
|
|
385 | $dialog->{tooltip} = "Press a key (click on the entry to make sure it has keyboard focus)"; |
|
|
386 | $vbox->add (my $entry = new CFClient::UI::Entry |
|
|
387 | on_changed => sub { |
|
|
388 | $self->send ("reply $_[1]"); |
|
|
389 | $dialog->destroy; |
|
|
390 | }, |
|
|
391 | ); |
|
|
392 | |
|
|
393 | $entry->focus_in; |
|
|
394 | |
|
|
395 | } else { |
|
|
396 | $dialog->{tooltip} = "Enter the reply and press return (click on the entry to make sure it has keyboard focus)"; |
|
|
397 | |
|
|
398 | $vbox->add (my $entry = new CFClient::UI::Entry |
|
|
399 | $flags & CS_QUERY_HIDEINPUT ? (hiddenchar => "*") : (), |
|
|
400 | on_activate => sub { |
|
|
401 | $self->send ("reply $_[1]"); |
|
|
402 | $dialog->destroy; |
|
|
403 | }, |
|
|
404 | ); |
|
|
405 | |
|
|
406 | $entry->focus_in; |
|
|
407 | } |
|
|
408 | |
|
|
409 | $dialog->show; |
|
|
410 | } |
353 | } |
411 | |
354 | |
412 | sub drawinfo { |
355 | sub drawinfo { |
413 | my ($self, $color, $text) = @_; |
356 | my ($self, $color, $text) = @_; |
414 | |
357 | |