GUIContainer onMouseEnter
by Robert Fritzen · in Torque 3D Beginner · 08/24/2013 (12:09 pm) · 8 replies
So I was looking through the source and was wondering why the generic mouse handles aren't available for all GUI Objects.
So, I went ahead and added some code to try to turn it on:
I then went ahead and coded up a new tooltip using a gui container for my game and I need the control to remain active while the mouse is over it. But, the onMouseEnter callback is not being triggered. The new callback appears in the list of options when using GuiContainer.dump();
Here is my GUI:
Ideas?
So, I went ahead and added some code to try to turn it on:
//.CPP CODE
IMPLEMENT_CALLBACK( GuiContainer, onMouseEnter, void, (), (),
"This is called when the mouse cursor moves over the control" );
IMPLEMENT_CALLBACK( GuiContainer, onMouseLeave, void, (), (),
"This is called when the mouse cursor leaves the control" );
//-----------------------------------------------------------------------------
void GuiContainer::onMouseEnter(const GuiEvent &event) {
onMouseEnter_callback();
}
//-----------------------------------------------------------------------------
void GuiContainer::onMouseLeave(const GuiEvent &) {
onMouseLeave_callback();
}
//.H CODE
class GuiContainer : public GuiControl {
.
.
.
protected:
DECLARE_CALLBACK( void, onMouseEnter, () );
DECLARE_CALLBACK( void, onMouseLeave, () );
.
.
.
public:
void onMouseEnter(const GuiEvent &);
void onMouseLeave(const GuiEvent &);I then went ahead and coded up a new tooltip using a gui container for my game and I need the control to remain active while the mouse is over it. But, the onMouseEnter callback is not being triggered. The new callback appears in the list of options when using GuiContainer.dump();
Here is my GUI:
%guiContent = new GuiControl(StoreHoverTooltip) {
position = "0 0";
extent = "1024 768";
minExtent = "8 2";
horizSizing = "right";
vertSizing = "bottom";
profile = "GuiDefaultProfile";
visible = "1";
active = "1";
tooltipProfile = "GuiToolTipProfile";
hovertime = "1000";
isContainer = "1";
canSave = "1";
canSaveDynamicFields = "1";
new GuiContainer(TooltipContainer) {
margin = "0 0 0 0";
padding = "0 0 0 0";
anchorTop = "1";
anchorBottom = "0";
anchorLeft = "1";
anchorRight = "0";
position = "0 0";
extent = "400 250";
minExtent = "8 2";
horizSizing = "relative";
vertSizing = "relative";
profile = "GuiDefaultProfile";
visible = "1";
active = "1";
tooltipProfile = "GuiToolTipProfile";
hovertime = "1000";
isContainer = "1";
canSave = "1";
canSaveDynamicFields = "0";
.
.
.
.
};
};Ideas?
About the author
Illinois Grad. Retired T3D Developer / Pack Dev.
#2
08/25/2013 (10:58 am)
They're there, I just didn't post them.
#3
08/25/2013 (12:31 pm)
You forgot to make the class header methods virtual as required://
public:
virtual void onMouseEnter(const GuiEvent &);
virtual void onMouseLeave(const GuiEvent &);
#4
08/25/2013 (12:43 pm)
Changing that had no effect either.
#5
If I can't figure this out, I'll just move the container of interest to be the head item and try it that way.
08/25/2013 (2:27 pm)
Quick update. I did some more fiddling around with it, and moved the callback to GuiControl (such that I now have mouse event callbacks on all of my controls). I'm finding it very odd that the GuiControl(StoreHoverTooltip) { and every other item in this gui is able to trigger the callback and yet the control I need to trigger it is not, this eludes me because GUIButtons use essentially the exact same code and they work perfectly fine.If I can't figure this out, I'll just move the container of interest to be the head item and try it that way.
#6
I've got the mouse event to work now by removing the GuiContainer and simply using the internal controls. Now I've got a new problem. I can use the new "tooltip" dialog fine, but when it's up, I can't click any buttons inside the GUI that creates the tooltip.
IE: User cursors over an image, the new tooltip pushes, and the user cannot click any buttons in the gui until the tooltip pops. How do I go about fixing this?
08/26/2013 (10:37 am)
Alright Another Update,I've got the mouse event to work now by removing the GuiContainer and simply using the internal controls. Now I've got a new problem. I can use the new "tooltip" dialog fine, but when it's up, I can't click any buttons inside the GUI that creates the tooltip.
IE: User cursors over an image, the new tooltip pushes, and the user cannot click any buttons in the gui until the tooltip pops. How do I go about fixing this?
#7
look up the MIT Version of GMK
its using Raycasts
08/26/2013 (11:26 am)
if am not mistaken you could do it the way GMK did it with the doors/ useable objectslook up the MIT Version of GMK
its using Raycasts
#8
08/31/2013 (3:19 pm)
@J0: I already got the mouse events working. I'm having an issue with one dialog "covering" up the other one now and I need the functionality of the "covered" dialog.
Torque Owner Nathan Martin
TRON 2001 Network
function TooltipContainer::onMouseEnter(%this) { // handle event here } function TooltipContainer::onMouseLeave(%this) { // handle event here }