Is there a way to make sure that certain button activates when two buttons are in same place?

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

Is there a way to make sure that certain button activates when two buttons are in same place?

Post by Bugala »

I am currently planning on having bigger box with a small box in corner on top of the button.

Idea here is that by clicking on that bigger box I can load a picture to be displayed on it, but by pushing that small corner box, I can delete the image.

Easiest would be to make two #SIMPLEBUTTONs, but having the bigger for example 200x200, and then have smaller box of size 10x10 as example which is placed on the corner of the bigger Button.

However, how does Hollywoods buttons work. That is there a sure way to make sure that when I click on that Smaller button, it actually does activate the smaller button instead of the bigger button?

Like If I use MakeButton twice, is it so that the Button I created last would be the one that would be activated when two buttons are at same location? Or is it random behavior?

Would have tested, but even if it works as expected, that doesn't mean it would always work necessarily, if there is some randomness in it.
plouf
Posts: 473
Joined: Sun Feb 04, 2018 11:51 pm
Location: Athens,Greece

Re: Is there a way to make sure that certain button activates when two buttons are in same place?

Post by plouf »

acoring to manual of MakeButton() (check in Z-order ) the last created overlaps previous but this is guarandeed in layers :)
definitely works in way created thought even without layers, but will be guaranteed in future (?)

i know you dont use layers ...
Christos
User avatar
airsoftsoftwair
Posts: 5446
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Is there a way to make sure that certain button activates when two buttons are in same place?

Post by airsoftsoftwair »

Bugala wrote: Wed Feb 14, 2024 4:44 pm Would have tested, but even if it works as expected, that doesn't mean it would always work necessarily, if there is some randomness in it.
It's not really random. All buttons are chained in a linked list to the current BGPic and then this list is checked against mouse events in the order of creation of the buttons so buttons created first should trigger first.
plouf
Posts: 473
Joined: Sun Feb 04, 2018 11:51 pm
Location: Athens,Greece

Re: Is there a way to make sure that certain button activates when two buttons are in same place?

Post by plouf »

airsoftsoftwair wrote: Mon Feb 19, 2024 9:32 pm It's not really random. All buttons are chained in a linked list to the current BGPic and then this list is checked against mouse events in the order of creation of the buttons so buttons created first should trigger first.
i would say its the opposite order the last created is the first triggered

Code: Select all

Function p_MyFunc(msg)
  Switch msg.action
  Case "OnMouseUp":
    DebugPrint("User left-clicked button", msg.id)
  EndSwitch
EndFunction
evtmatch = {OnMouseUp = p_MyFunc}


MakeButton(1,#SIMPLEBUTTON,1,1,100,100,evtmatch)
MakeButton(2,#SIMPLEBUTTON,1,1,50,50,evtmatch)

Box(1,1,100,100,#RED)
Box(1,1,50,50,#BLUE)


Repeat
	WaitEvent()

Forever
Christos
User avatar
airsoftsoftwair
Posts: 5446
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Is there a way to make sure that certain button activates when two buttons are in same place?

Post by airsoftsoftwair »

plouf wrote: Tue Feb 20, 2024 5:54 am i would say its the opposite order the last created is the first triggered
Yup, right, looks like the list is traversed from tail to head so it makes sense that last created triggers first.
Post Reply