Roughly what I am trying to do:
I have a class which inherits from panel, it is just a big grid.
Inside are child widgets, they are boxes with text etc contained in them. (They also inherit from panel).
What I want to happen:
When I click on a "box" (child panel) I want to set it as selected.
When I click an already selected box, I want to be able to hold the LMB and move it.
When I click elsewhere on the grid I want to deselect any boxes that are selected.
What I tried so far:
#1. override leftMousePressed on both the grid, and the box. In this case the parent "grid" responds and appears to "eat" the event. The child's method never triggers even if it was under the cursor.
#2. Do not override. Both grid and box use "onClick" to call their own methods. In this case, first the parent and then the child respond to the "onClick".
So my actual question then, is what is the difference between overriding and signals? I assume signals are preferred when using stock tgui::widgets, and the override is needed when doing custom functionality. If I override, then I need to handle passing the event to the child widgets even if I inherited from a widget which normally has sub-widgets?
I have a class which inherits from panel, it is just a big grid.
Inside are child widgets, they are boxes with text etc contained in them. (They also inherit from panel).
What I want to happen:
When I click on a "box" (child panel) I want to set it as selected.
When I click an already selected box, I want to be able to hold the LMB and move it.
When I click elsewhere on the grid I want to deselect any boxes that are selected.
What I tried so far:
#1. override leftMousePressed on both the grid, and the box. In this case the parent "grid" responds and appears to "eat" the event. The child's method never triggers even if it was under the cursor.
#2. Do not override. Both grid and box use "onClick" to call their own methods. In this case, first the parent and then the child respond to the "onClick".
So my actual question then, is what is the difference between overriding and signals? I assume signals are preferred when using stock tgui::widgets, and the override is needed when doing custom functionality. If I override, then I need to handle passing the event to the child widgets even if I inherited from a widget which normally has sub-widgets?
QuoteUnlike with the SubwidgetContainer which forwards all events to the correct subwidget, if you inherit from Widget directly then you will likely have to handle some events yourself.So I see "panel" is a "container" but not a "SubWidgetContainer", so I guess it also "does not forward"?