How to handle widget events?

thucanh

02-07-2008 13:50:25

Hello,

I'm trying to apply MyGUI to a simple 3D viewer. It works fine and very easy to use. Now I have 2 questions:

1. How can I catch and handle mouse hover and out widget events? (My viewer uses mouse to rotate the model and I want to disable rotation when moving/dragging a MyGUI Window around).

2. The RenderBox with zoom and rotation is great! But I wonder if there were any properties I can set so that object can be rotated in abitary direction, not horizontal or vertical? (I saw rotation angle property in LayoutEditor but don't know how it work? :))

Few lines of code would be much appreciated.

Thanks,

my.name

02-07-2008 15:09:03

1.


/** Inject MouseMove event
@return true if event has been processed by GUI
*/
bool injectMouseMove(int _absx, int _absy, int _absz);



bool BasisManager::mouseMoved( const OIS::MouseEvent &arg )
{
if (mGui->injectMouseMove(arg)) {
return true;
}
// your code
}

thucanh

03-07-2008 05:38:37

Thank you for your reply.

I knew this way and tried it already. But I need more flexible control over these events. For example, I may disable rotating when dragging this window, but not when dragging another. So I want to set a flag to determine which window I'm dragging.

Is this possible with MyGUI?

Altren

03-07-2008 23:22:34

Use eventMouseMove /** Event : Mouse move over widget.\n
signature : void method(MyGUI::WidgetPtr _sender, int _left, int _top)\n
@param _left, _top - pointer position
*/
EventInfo_WidgetIntInt eventMouseMove;

thucanh

09-07-2008 06:24:45

Sorry for my late reply.

I tried eventMouseMove for Mouse hover and eventLostMouseFocus for mouse out. It seems work.

Thank you,

thucanh

thucanh

17-07-2008 09:33:17

It's me again,

I tested the widget mouse events (Drag, Move, SetFocus, LostFocus) on Window widgets and found that these event are only fired when the mouse moves over client area of Window. But when mouse move on window title bar, events were not fired at all. Is this intentional behaviors of Window widgets???

Can you give me a clue how to catch window drag event and if I can catch drag event, how can I know drag is finished? (I can not find any event for that)

thucanh

Altren

22-07-2008 23:17:27

I tested the widget mouse events (Drag, Move, SetFocus, LostFocus) on Window widgets and found that these event are only fired when the mouse moves over client area of Window. But when mouse move on window title bar, events were not fired at all. Is this intentional behaviors of Window widgets???Well, now you cannot catch events from part of widgets that are also widget.Can you give me a clue how to catch window drag event and if I can catch drag event, how can I know drag is finished? (I can not find any event for that)Can you explain where you need it.

thucanh

23-07-2008 07:41:43

Can you give me a clue how to catch window drag event and if I can catch drag event, how can I know drag is finished? (I can not find any event for that)Can you explain where you need it.

Well, all I want is:
My sample viewer uses mouse to rotate the model and I want it to stop rotating when I dragging a MyGUI Window around.

At first, I thought it could be solved by using eventMouseMove, but i can not catch that event of subwidget (as you said). Then I think of eventMouseDrag ...

Is there any better and easier ways to get this work?

Altren

23-07-2008 11:12:57

Of course.
You can use injectMouseMove return value:
/** Inject MouseMove event
@return true if event has been processed by GUI
*/

mouseMoved( const OIS::MouseEvent &arg )
{
if (mGUI->injectMouseMove(arg))
{
// mouse over GUI
}
else
{
// rote or do whatever you want
}
}