Recent

Author Topic: Buttons Multiselection  (Read 2016 times)

hathanhthang97_vt

  • Newbie
  • Posts: 3
Buttons Multiselection
« 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. :-\ :-\

Zvoni

  • Hero Member
  • *****
  • Posts: 2319
Re: Buttons Multiselection
« Reply #1 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
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad

howardpc

  • Hero Member
  • *****
  • Posts: 4144
Re: Buttons Multiselection
« Reply #2 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.

hathanhthang97_vt

  • Newbie
  • Posts: 3
Re: Buttons Multiselection
« Reply #3 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?

hathanhthang97_vt

  • Newbie
  • Posts: 3
Re: Buttons Multiselection
« Reply #4 on: June 27, 2018, 07:05:12 pm »
Oh howardpc, sorry for missing your file. Thank you a lot.

 

TinyPortal © 2005-2018