Recent

Author Topic: [SOLVED] Dialog that requests user input with default entry  (Read 1527 times)

fatmonk

  • Sr. Member
  • ****
  • Posts: 252
[SOLVED] Dialog that requests user input with default entry
« on: March 22, 2021, 04:59:52 pm »
Is there a standard LCL dialog that requests user input with a default value - like InputBox - but also registers whether the user clicked OK or Cancel - like InputQuery?

-FM
« Last Edit: March 22, 2021, 05:39:17 pm by fatmonk »

lucamar

  • Hero Member
  • *****
  • Posts: 4217
Re: Dialog that requests user input with default entry
« Reply #1 on: March 22, 2021, 05:26:01 pm »
Doesn't InputQuery do exactly that?

For example:
Code: Pascal  [Select][+][-]
  1. var
  2.   AVal: String;
  3. begin
  4.   AVal := 'Default value';
  5.   if not InputQuery('Query', 'Input something', AVal) then
  6.     ShowMessage('Cancelled');
  7. end;
results in the atttached image
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus/FPC 2.0.8/3.0.4 & 2.0.12/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

fatmonk

  • Sr. Member
  • ****
  • Posts: 252
Re: Dialog that requests user input with default entry
« Reply #2 on: March 22, 2021, 05:39:04 pm »
Aha.. the last argument also sets the default value... makes sense, but I didn't get that from the documentation - I thought it was just for the result.

Thanks,

-FM

lucamar

  • Hero Member
  • *****
  • Posts: 4217
Re: [SOLVED] Dialog that requests user input with default entry
« Reply #3 on: March 22, 2021, 05:44:42 pm »
If it's any consolation, I wasn't quite sure either and had to test it ;)
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus/FPC 2.0.8/3.0.4 & 2.0.12/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

dsiders

  • Hero Member
  • *****
  • Posts: 1525
Re: [SOLVED] Dialog that requests user input with default entry
« Reply #4 on: March 22, 2021, 07:05:18 pm »
If it's any consolation, I wasn't quite sure either and had to test it ;)

Docs have been updated to include the omission.

There is also a variant that has arrays of Prompts and Values. That one was not mentioned in the docs at all.

lucamar

  • Hero Member
  • *****
  • Posts: 4217
Re: [SOLVED] Dialog that requests user input with default entry
« Reply #5 on: March 22, 2021, 08:22:36 pm »
There is also a variant that has arrays of Prompts and Values. That one was not mentioned in the docs at all.

It is "mentioned" (at least for 3.2.0); what it isn't is explained, as in: "WTH does it do?" :o

Fact is, most of Dialogs procedures and functions are rather sketchily explained in the docs and one is left with almost no resource but trying them to see what they do.

Which, depending on the p.o.v., might not so bad; I'd do it nevertheless :)


* ETA: for completeness sake (though it's easy to guess) what it does is allow to prompt for and return several values instead of just one.
« Last Edit: March 22, 2021, 08:25:13 pm by lucamar »
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus/FPC 2.0.8/3.0.4 & 2.0.12/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

 

TinyPortal © 2005-2018