Array of buttons

Hey guys, I am pretty new to programming and Xojo as well, so hopefully you can enlighten me…

I am trying to display (in a window) a dynamic matrix/array of bevel buttons that represent the rooms of a hotel. Some hotels may have 20 rooms, some may have 400.

If you click in one of this buttons the room properties/details should pop up.

I have it kind of working now, but the problem is, If I display more than 200 buttons the display process becomes slow and sluggish. And every time the window (and the buttons) updates it becomes even slower. I am not sure what would be the best way to either code this OR maybe find other solution to display 400 clickable objects on an eventually scrolling pane.

PS. I Tried to make an array of buttons on a canvas (to be able to scroll) but it was EVEN slower.

Any ideas ?
Thanks

Use a CANVAS… and what I would do (based on what you said above)… it not create a bazillon of them… but just one, and then use the X,Y coordinates of a mouse click within the canvas to determine what “room”. If done properly, the hotel layout can be stored in a database or XML file, and the actual code doesn’t change … just the contents of the database depending on the hotel involved.

Hey Dave, thanks for the reply… ! Not sure I got your idea…

Use a canvas… ok… and then… draw as many “buttons” I want and get the coordinates of the mouse click to determine what “button” was pressed ? Is this your suggestion ?

If that is the case… it is mucho more work… because also these “buttons” (or clickable surfaces) should have some properties, like a label, a color… etc… just like… a button ! :slight_smile:

But I can imagine that drawing that on a canvas and getting the mouse clicks programmatically will be faster than deploying hundreds of colored buttons… Am I right ?

Nope @Dave S gave you the easy way.

You can write a function to draw each state of the button. Then you can pass the appropriate function the room number and it can draw that button for you.

ok… I think I am starting to get the idea… I will have to start all over again… geez… this is what learning is about I guess…
thanks!

Wouldn’t it be easier on the end user to just type in the room number?

I would like the user to have a fast visual feedback about the whole room situation. With different colors having different meanings, locked rooms, empty rooms, “to be cleaned” rooms, etc…

1 Like

Well, I finally decided it’s going to be a dynamic listbox, with labeled, coloured, clickable cells.