passthrough on gui controls
by Rex Hiebert · in Torque 3D Professional · 10/15/2009 (10:03 am) · 1 replies
I ran into an issue where I wanted to have a number of fields, both text and graphic, on a button. I wanted this button to still allow clicking but when the other controls were on it, they kept stealing the mouse events. I looked around and there was some discussion about adding a field and extra code but no real examples. So I started poking around and found that a search is launched to find which control was hit. There was even a var called "canHit". So.... in "guiControl.cpp" in the function:
That's it. "canHit" defaults to "true" so everything behaves normally but you now have the option to set it to false in the UI editor. The control can be seen but the mouse events pass down to the containing control (These are not the controls you are looking for. Move along!). I haven't noticed any issues with this method. Let me know if you find something.
void GuiControl::initPersistFields()
{
// Things relevant only to the editor.
addGroup("Gui Editing");
addField("isContainer", TypeBool, Offset(mIsContainer, GuiControl));
addField("canHit", TypeBool, Offset(mCanHit, GuiControl)); // <<< ADDED
endGroup("Gui Editing");
...That's it. "canHit" defaults to "true" so everything behaves normally but you now have the option to set it to false in the UI editor. The control can be seen but the mouse events pass down to the containing control (These are not the controls you are looking for. Move along!). I haven't noticed any issues with this method. Let me know if you find something.
Torque 3D Owner Lethal Concept
For T3D 1.1 I've found so far:
In guiCanvas.cpp in rootMouseDown() change
to
if(!controlHit /*<< dirty fix! see comment below*/ || !controlHit->getControlProfile()->mModal ) // Due to the exposition of mCanHit, ctrl may be NULL -MD continue;In guiEditCtrl.cpp in onMouseDown() and onMouseUp() insert after:
this:
//< insert start // Dirty Hackfix // Due to the exposition of mCanHit, ctrl may be NULL -MD if(! ctrl) ctrl = this; //> insert endI'll post more as I find them.