Set widget to unclickable
« on: 06 March 2019, 15:18:08 »
Hello everyone,

How can I make a widget unclickable (e.g. with a tgui::Label) ? And by that, I mean tgui::handleEvent() stops returning me true when I click/hover to the widget.
I tried with ignoreMouseEvents(), but the tgui::handleEvent() keeps returning me true.
 
Thanks

*

texus

  • *****
  • 1336
    • View Profile
    • Texus's Blog
Re: Set widget to unclickable
« Reply #1 on: 06 March 2019, 20:01:46 »
It seems like ignoreMouseEvents doesn't do anything at all for Label, the property was added in both Label and Picture but is only used in Picture. I'll fix this soon.
Although handleEvent should return false after I fix it (unless there is another widget behind the label), what you need is the setEnabled function.

ignoreMouseEvents was added to allow a mouse event to reach the widget behind the label or picture, but to make a widget (any widget) completely ignore events, you should disable it:
label->setEnabled(false);

Re: Set widget to unclickable
« Reply #2 on: 06 March 2019, 21:03:28 »
Oh okay, I understand.
Indeed, it works with setEnabled, thanks for your answer !