• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Do we need GetClickedButton in TriggerRegisterButtonDialogEvent

Status
Not open for further replies.
Level 15
Joined
Aug 7, 2013
Messages
1,338
Hi,

For this event call TriggerRegisterDialogButtonEvent(t, goalBttn) , do we even need to check what button is clicked in the trigger actions. Or does this trigger only fire off if that exact button is clicked?
 
Hi,

For this event call TriggerRegisterDialogButtonEvent(t, goalBttn) , do we even need to check what button is clicked in the trigger actions. Or does this trigger only fire off if that exact button is clicked?

It only fires if the button that goalBttn points to is clicked, so you don't have to use GetClickedButton(). Just note that if you clear the dialog and add buttons again, you'll have to register the event again because you'll have a separate button handle.

Although, I don't even remember if TriggerRegisterDialogButtonEvent() works. Maybe it does. I forget. I just remember having weird issues with it. :p
 
Level 15
Joined
Aug 7, 2013
Messages
1,338
It only fires if the button that goalBttn points to is clicked, so you don't have to use GetClickedButton(). Just note that if you clear the dialog and add buttons again, you'll have to register the event again because you'll have a separate button handle.

Although, I don't even remember if TriggerRegisterDialogButtonEvent() works. Maybe it does. I forget. I just remember having weird issues with it. :p

Alright well it seems to work, but I've run into a problem...

JASS:
    method setBttnGoal takes button goalBttn returns nothing
        local trigger t = CreateTrigger()
        set this.goalBttn = goalBttn
        call TriggerRegisterDialogButtonEvent(t, goalBttn)
        call TriggerAddCondition(t, Condition(function buttonClickMain))
        set t = null
    endmethod

This method works, in that when "goalBttn" is clicked, the trigger fires off.

But, when I compare "this.goalBttn" to "GetClickedButton()," the trigger claims the two aren't equal. I don't see how that's friggin possible. The handle didn't change either...Unless you can't use "GetClickedButton()" in this event?

Edit: Ok, I'm not losing my mind, and I was right. This seems really, really dumb, but "GetClickedButton()" actually returns null if you register this event!!! I know it seems redundant, but I actually need the "GetClickedButton()"!!
 
Level 26
Joined
Aug 18, 2009
Messages
4,097
It only fires if the button that goalBttn points to is clicked

Since this sounds misleading:
The button you registered the event for does not change with the content of the variable, you do not register the variable.

We avoid TriggerRegisterDialogButtonEvent because you can neither use GetClickedButton nor GetClickedDialog, so the trigger instance would have to be absolutely exclusive to the single button and have the data customizedly pre-attached in order be able to read either. Use TriggerRegisterDialogEvent instead.
 
Status
Not open for further replies.
Top