I appear to be struggling with setting various buttons states to Pressed.

Some times a previously pressed button will be set to pressed after I click another button, but not the currently set button...

I also see the hover does a flash after pressing, is this resetting the state?

All these buttons have had toggle_mode set to true.

I've played with:

if n == 0:
o_btn0.set_pressed_no_signal(true)

o_btn0.pressed = true if n == 0 else false

o_btn0.set_pressed(true if n == 0 else false)

Thanks

  • MagickPanda replied to this.
  • I've had a similar issue, and resolved it by changing the button's focus_mode property to Control.FOCUS_NONE.

    totoro
    hmm have you used release signal when certain button get released?
    You could just keep track of button pressed and released signals to set button 'pressed' state to either true or false.

      MagickPanda

      Cheers

      I'm not seeing a released, I am seeing button_up(), also a taggled() event handler.

      I'm also thinking that from Control the gui_input(event) is not handling the button press events.

      The order in which the button events fire are: taggled, pressed and then button_up (ignoring button_down)

      In each I've tried the following:

      func _on_btn2_button_up():
      	print("btn2 up")
      	#o_btn2.pressed = true
      	#o_btn2.set_pressed(true)
      	o_btn2.set_pressed_no_signal(true)

      If I change the btn for the output of the pressed, then it works.

      So I'm thinking that a callback is added after the button_up event which normally reverts the button back to normal state. Is there any way to access / override that?

      In most GUI button click event logics, you need both clicked and released(button down and up event must be fired inside button's bouding box rect) to determine wether a button is clicked or not.

      So the most reliable and simplest way to test if button is back to default state is to listen to its 'up'/'released' event.

      I've had a similar issue, and resolved it by changing the button's focus_mode property to Control.FOCUS_NONE.