Lazarus

Programming => LCL => Topic started by: hathanhthang97_vt on June 27, 2018, 11:27:07 am

Title: Buttons Multiselection
Post by: hathanhthang97_vt on June 27, 2018, 11:27:07 am
     Hi everyone  :) :)
     I've just started learning about lazarus and I have a problem:
     I created some buttons (button1, button2,...) and I want to make a multiselection of them. Particularly, I wanna press leftmouse button and 'Ctrl' on keyboard at the same time to click each button, or press 'Ctrl' + 'A' to select all of them. However, I actually don't know where I should start and also how to do that.
Could you give me some advice and the instruction to do that?
     Thank you so much and hope to see your feedback. Sorry for my poor English. :-\ :-\
Title: Re: Buttons Multiselection
Post by: Zvoni on June 27, 2018, 11:48:55 am
Errr... why would you want a multi-select-option for command-buttons?
I understand multiselect, say in a listbox, but why for buttons?

Think about it:
You achieve your goal to select-multiple buttons in one go (either clicking consecutively with CTRL held down, or with a CTRL+A), then what?
Execute some code?
Execute the code within the Click-Events of each selected button? If Yes, in what order?
If you implement the multiselect in the usual way (aka what Endusers are used to), the moment you click on another button to execute something, all those selected buttons would lose its selection-status.
I'd think really hard if you really want to do something like that
Title: Re: Buttons Multiselection
Post by: howardpc on June 27, 2018, 12:24:13 pm
As Zvoni writes, only one button at a time can have focus, so Ctrl-A makes little sense.
Attached is a simple example to get you started.
Title: Re: Buttons Multiselection
Post by: hathanhthang97_vt on June 27, 2018, 06:26:19 pm
Thank you so much Zvoni and howardpc
Oh...I got it, actually this is a task in my exercise that we have to do some manipulations like doubleclick to create components, drag and drop them, and make multiselection of them and then delete the selected components. Firstly we choose buttons as the components we have done with, but it seems that it would be more suitable if I change into another kind of component. So is Image or Shape ok?
Title: Re: Buttons Multiselection
Post by: hathanhthang97_vt on June 27, 2018, 07:05:12 pm
Oh howardpc, sorry for missing your file. Thank you a lot.
TinyPortal © 2005-2018