* * *

Author Topic: Help with TComboBox  (Read 646 times)

aacury

  • Newbie
  • Posts: 4
Help with TComboBox
« on: October 31, 2018, 07:45:07 pm »
Hi guys,

I've just started working with Lazarus and I've got a simple (I guess) question:

I'm creating a TCombobox with 5 items. What I want is: when the user chooses one of the items, an input dialog appears so the user can input three or four values (that will be used later in my code).

Thus, my question is: how do I make an input dialog appear when a given TCombox item is selected?

Many thanks,
Alex

lucamar

  • Sr. Member
  • ****
  • Posts: 316
Re: Help with TComboBox
« Reply #1 on: October 31, 2018, 08:36:25 pm »
Thus, my question is: how do I make an input dialog appear when a given TCombox item is selected?

Add a handler for the ComboBox.OnSelect event, check which item was selected with ComboBox.Items[ComboBox.ItemIndex] (or just ComboBox.ItemIndex if the order is predefined) and execute the proper dialog.
Been there, done that ... barely kept the timelines.
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus 1.8.4/fpc 3.0.4 - Ubuntu 10, Kubuntu 14, Windows XP SP3 (Home & Prof.) and various DOS incarnations.

aacury

  • Newbie
  • Posts: 4
Re: Help with TComboBox
« Reply #2 on: November 01, 2018, 01:54:39 pm »
Thanks for your help. The handler did the trick.

However, which command should I call for the input dialog? (I need one so the user can input three or four values that will be used later in my code)

Thanks again.

Zoran

  • Hero Member
  • *****
  • Posts: 1275
    • http://wiki.lazarus.freepascal.org/User:Zoran
Re: Help with TComboBox
« Reply #3 on: November 01, 2018, 02:07:53 pm »
Thanks for your help. The handler did the trick.

However, which command should I call for the input dialog? (I need one so the user can input three or four values that will be used later in my code)

Thanks again.

You should design the dialog yourself for your need. Is is rather easy in Lazarus (start with File->New Form from the main menu).
Of course there are no predefined input dialogs for every situation. See what is offered here: http://wiki.freepascal.org/Dialog_Examples#Text_input_Dialogs


lucamar

  • Sr. Member
  • ****
  • Posts: 316
Re: Help with TComboBox
« Reply #4 on: November 01, 2018, 03:03:28 pm »
However, which command should I call for the input dialog? (I need one so the user can input three or four values that will be used later in my code)

You should design the dialog yourself for your need. Is is rather easy in Lazarus (start with File->New Form from the main menu).

Another handy trick is to implement your dialogs as frames instead of forms; that way you can use just one "dialog" form showing the correct frame. It's a little more work (though not that much) but allows you to reuse those same frames elsewhere if you change your UI type at some future time.
Been there, done that ... barely kept the timelines.
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus 1.8.4/fpc 3.0.4 - Ubuntu 10, Kubuntu 14, Windows XP SP3 (Home & Prof.) and various DOS incarnations.

aacury

  • Newbie
  • Posts: 4
Re: Help with TComboBox
« Reply #5 on: November 01, 2018, 06:58:55 pm »
Hi guys,

thanks again for the help. I managed to make it work.

However, like I said, I need an input dialog for three or four user inputs. It seems that both InputBox and InputQuery accept just the one, right?

Is there any simpler way to create such thing and store the inputs in a vector?
« Last Edit: November 01, 2018, 07:47:27 pm by aacury »

Thaddy

  • Hero Member
  • *****
  • Posts: 7087
Re: Help with TComboBox
« Reply #6 on: November 01, 2018, 07:05:42 pm »
Yes. You need to design a form with X inputs with fsDialog style. This not complex. Try that first yourself. We will give an example if you can not figure it out.
inline variables like in D10.3 are a bit like Brexit: if you are given the wrong information it sounds like a good idea. Every kid loves candy, but it makes you fat and your teeth will disappear.

lucamar

  • Sr. Member
  • ****
  • Posts: 316
Re: Help with TComboBox
« Reply #7 on: November 02, 2018, 01:21:24 am »
As a teaser, here is a 10 minutes, Q&D example of how it may look :D
Been there, done that ... barely kept the timelines.
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus 1.8.4/fpc 3.0.4 - Ubuntu 10, Kubuntu 14, Windows XP SP3 (Home & Prof.) and various DOS incarnations.

aacury

  • Newbie
  • Posts: 4
Re: Help with TComboBox
« Reply #8 on: November 02, 2018, 09:53:18 am »
As a teaser, here is a 10 minutes, Q&D example of how it may look :D

Did you use the fsDialog mentioned by Thaddy?

Zoran

  • Hero Member
  • *****
  • Posts: 1275
    • http://wiki.lazarus.freepascal.org/User:Zoran
Re: Help with TComboBox
« Reply #9 on: November 02, 2018, 11:05:22 am »
As a teaser, here is a 10 minutes, Q&D example of how it may look :D

Did you use the fsDialog mentioned by Thaddy?

Before asking, you tried with and without fsDialog yourself of course, didn't you? What differences did you notice?

lucamar

  • Sr. Member
  • ****
  • Posts: 316
Re: Help with TComboBox
« Reply #10 on: November 02, 2018, 01:34:17 pm »
Did you use the fsDialog mentioned by Thaddy?

Yes, I did; they're no much different in this theme (Oxygen-GTK) but p.e. note the lack of "maximize" button. Zoran is right: try it yourself and look.
Been there, done that ... barely kept the timelines.
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus 1.8.4/fpc 3.0.4 - Ubuntu 10, Kubuntu 14, Windows XP SP3 (Home & Prof.) and various DOS incarnations.

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus