Questions regarding buttons without layers

Discuss any general programming issues here
Post Reply
Bugala
Posts: 1178
Joined: Sun Feb 14, 2010 7:11 pm

Questions regarding buttons without layers

Post by Bugala »

As I in my last game tried no layers approach, and I actually liked it, I am now thinking of using it in next one too. However, there are couple of questions regarding buttons that I am still wondering.

When using layers, one of the nice things was that I could attach a button to a layer. When I would move that layer (for example by dragging it with a mouse) so would the button.

Since in no layers approach, it seems to me that i am restricted to using #simplebuttons only, then dragging button around is not so easy anymore. Is there any way to have similar approach to a button without layers, as in having button attached to a layer? Or is my only option that when the button graphics move, I will recreate the button?

Another question is about how is the button order determined in non layer approach.

In layer approach if I had two layers on top of each other, it was usually the top layers button that reacted (although this wasnt officially so, it seems in practice it usually was that way).

As example, if without layers using two simple buttons, first one a large rectangle area, and then the next one smaller, inside that larger rectangle area, then if i click on that smaller area, then which button would be activated, the big or the small one?

Idea in this being that there could be a big box that when you click, you could move it around, and this smaller box would be some button inside this bigger box that is actually meant to be clicked.
User avatar
airsoftsoftwair
Posts: 5433
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Questions regarding buttons without layers

Post by airsoftsoftwair »

Bugala wrote: Fri Aug 09, 2019 9:16 am Since in no layers approach, it seems to me that i am restricted to using #simplebuttons only, then dragging button around is not so easy anymore. Is there any way to have similar approach to a button without layers, as in having button attached to a layer? Or is my only option that when the button graphics move, I will recreate the button?
You don't have to use buttons at all. Just catch the mouse clicks and then handle the button logic in the event handler. It's really not that difficult.
Bugala wrote: Fri Aug 09, 2019 9:16 am As example, if without layers using two simple buttons, first one a large rectangle area, and then the next one smaller, inside that larger rectangle area, then if i click on that smaller area, then which button would be activated, the big or the small one?
Overlapping button behaviour is currently undefined. Since Hollywood stores all these buttons inside a linked list, the ones defined earlier will probably trigger first because they're at the start of the list.
Bugala
Posts: 1178
Joined: Sun Feb 14, 2010 7:11 pm

Re: Questions regarding buttons without layers

Post by Bugala »

airsoftsoftwair wrote: Fri Aug 09, 2019 5:13 pm You don't have to use buttons at all. Just catch the mouse clicks and then handle the button logic in the event handler. It's really not that difficult.
Yes, hadn't actually even thought of that before. Had gotten so used to using layer buttons that didn't even think of other possibilities. I guess I will look for my own button system. In addition, this brings me the possibility of controlling the before mentioned situation of a smaller button being inside a bigger button.
User avatar
jPV
Posts: 603
Joined: Sat Mar 26, 2016 10:44 am
Location: RNO
Contact:

Re: Questions regarding buttons without layers

Post by jPV »

airsoftsoftwair wrote: Fri Aug 09, 2019 5:13 pm
Bugala wrote: Fri Aug 09, 2019 9:16 am As example, if without layers using two simple buttons, first one a large rectangle area, and then the next one smaller, inside that larger rectangle area, then if i click on that smaller area, then which button would be activated, the big or the small one?
Overlapping button behaviour is currently undefined. Since Hollywood stores all these buttons inside a linked list, the ones defined earlier will probably trigger first because they're at the start of the list.
With a quick test it seems that the last created button was taken in overlapping situation.. so in this case if you first create the big button and then small one, then it works as wanted. At least on my setup it worked like that, but if there might be some randomness...
Post Reply