Button event handler
I am using a handler to react on button clicks:
Is that the right way? If yes, then we have a minor problem: Clicking outside the button, dragging the mouse over the button and releasing the mouse fires the event. A bit strange ...
That is the correct way to define a handler for a button, but those events shouldn't result in that event being fired. I'm guessing your button has the gainFocusOnClick property set to false? I have modified the inject mouse down/up methods, now widgets that don't have focus set on click still receive mouse up/click, but only if mouse went down on them. Regarding the clicking outside and firing.. I would have to repro that, I can't think of how that is possible..
Everything is checked into SVN now. (your other posts included
Not the button, but the parent window (gainFocusOnClick ==false) No idea, why I did it, since this is a part of the user interface, that doesn't need the special focus behaviour. Removed it now. Doesn't affect the problem.
Clicking outside the button, dragging the mouse over the button and releasing the mouse fires the event.
Re-reading this, that statement is all one use case right? I thought clicking outside of the button was causing the button to receive a mouse button up event..
Well I think I know what I need to do to fix the problem. Originally I checked if the active widget was the mouse over widget, if so, then mouse up would fire (active means mouse went down on it). But now that we have cases where mouse goes down and active widget does not change, this check doesn't work so well. I already have an array that records what widget's button down went on, so I will just revert to using that method.
Maybe the button is active, and you click on something that doesn't change active widget, and then you drag and release over the button? This would make the active and mouse over widget the same, causing mouse button up event to be fired.
Maybe the button is active, and you click on something that doesn't change active widget, and then you drag and release over the button?
Don't think so. I tried it with different buttons. Works with every single one. They can't be all active at the same time.
You click on button 1. You LMB down on button 1, drag cursor to button 2, and release LMB. Button 2 receives mouse up event? Both buttons do not have mGainFocusOnClick set to false, right? I thinkI defaulted that value to true but I can't be sure..
I tested this a while back and it worked. I will change it back like I said earlier, but the current method shouldn't be failing unless due to mGainFocusOnClick manipulation. I'll have to see if I can repro at home.
You click on button 1. You LMB down on button 1, drag cursor to button 2, and release LMB. Button 2 receives mouse up event?
Yes. Doesn't matter, if I start the drag on another button or on the window (outside any other widget). Same problem. I removed all setGainFocusOnClick calls. Still the same problem.
Ok I'll fix this tonight, stepping in should easily tell me what is going on, I just have to mouse down on one widget, drag and mouse up on another, and hit a breakpoint before firing mouse button up event.
mGainFocusOnClick was set to false by default..
By default widgets do gain focus on click. I changed this, and I do not see the mouse button up issue.
how do i recover this behavior?
At the moment i am coding a small shortcut bar and i want to drag and drop the actionitems placed in this bar.
Therfore i click on the actionitem in the upper left with the LMB. Hold the LMB and move it to the wanted place in the shortcutbar (might be lower right). Then release the LMB.
I received an EVENT_MOUSE_BUTTON_DOWN on the source widget and i need an EVENT_MOUSE_BUTTON_UP on the target widget.
How do i do this?
i toggled the setGainFocusOnClick() on the widget but it dosent work for me....
Drag and Drop widget functionality is on my TODO list, but I'm nowhere near that stage.
You receive a EVENT_MOUSE_BUTTON_UP event on the source widget, right?
Add an event handler to source widget for BUTTON_UP, and check if the mouse is within target widget bounds.
I disabled the ability to detect BUTTON_UP on a widget that has not already received a BUTTON_DOWN event.
hmmm.. i am receiving no EVENT_MOUSE_BUTTON_UP at all. for me one solution can be to set a FLAG on the widget so that it can fire the BT_UP even if it didn't got an BT_DOWN Event.
This is my way for the drag and drop.
The shortcutbar has an array of widgets (Image) x10 and y4.
Every widgets receives 2 unique events BTN_UP and BTN_DWN.
When i press the LMB at one widget i store the type (actionitem) remove it from the actionitemarray (same as the widgetarray only with enums filled).
Moving the cursor to the wanted position and now i wating for the BTN_UP event to store the current actionitem.
rather simple but i am not receiving the BTN_UP event...
I forgot to ask, but I'm guessing the image widgets are not actually moving with the mouse? For example, when you left click+drag the window titlebar, the window moves relative to the cursor. Is the same behavior applied to your images? When you release the left button, if the cursor is not over the same widget the mouse went down on, the BUTTON_UP event will not be fired.
I could double check the TitleBar widget receives BUTTON_UP, if this looks like a bug.
What do you mean by "x10 and y4". Are those dimensions, or a position?
(I love screenshots..
the origin widget is not moving. i have a 'master_ai_widget' which changes the texture and this is moving when i press the LMB.
here is a screenshot
'the icons are just for testing'
you are right x10 and y4 are the dimensions.
as you can see on the screenshot i have no titelbar at all.
I dont think that this is a bug. the reason is that the widget will not fire an event if it not former receives an BTN_DOWN...
First of all, I'd like to say I'm really happy and excited to see the screenshot you posted, gives me a lot more motivation to work hard!
Back to the topic. Is it possible to drag the image with the cursor. I'm trying to visualize what you are left clicking on, and where you want to place it.
If you drag the icon with the cursor, you can do what I posted above. If you don't drag it, my question is: do any of the icons ever move outside of that box? You can make LEFT_DOWN select an icon, and LEFT_DOWN place the icon. When Sheet::MOUSE_ENTER occurs, selected icon becomes NULL.
thx for the comment to the screen... quickgui fits very well into my needs and this game. quickgui is a pleasure to work with especially when i look at the bloated cegui.
It is possible to move with the cursor and attached ActionItem out of the main widget.
Another Screen with the AI attached to the cursor.
something to remind. this shortcutbar has 42 widget inside. 40 for the actionitems and 1 for the window and 1 for the debug text at the bottom. every widget fires the event MOUSE_ENTERED and MOUSE_LEAVE but has all the same methode for calling. the reason is to take care of the movementpoint where the character is movin to wenn you click on the ground... (if i add those widget as childs to the window do i can reduce the amount of eventhandlers?)
If you drag one actionitem out of the window you remove it from the shortcutbar. And i want the normal behavior like under windows if you want to move the AIs.
Later there will be another source window placed in the center of the screen. In this source window youll select the wanted ActionItem and move it with Drag&Drop to the shortcutbar.
Therefore i need this behavior LMB_UP.
A the evening (in germany gmt+1) ill look into the quickgui code and try to add a FLAG to the widget. if it works it might be a small improvement to your great work
When you drag the action item, it receives LMB+UP when you release the mouse button right?
Regarding the widgets all needing event handlers, I previously made this function to propogate events:
void Widget::setPropogateEventFiring(Event e, bool propogate);
The 40 widgets can pass up MOUSE_ENTERED and MOUSE_LEAVE events using this method.
Improvements are welcome.
one small problem might be the actionitem direct under the cursor. it always receives the event and not the wanted widget in the shortcutbar.
the function setPropageteEventFiring() is integrated in the version 097. and at the moment i am having a lot of trouble migrating from 096b to 097(svn).
Our client is coded in vs2003 for the compatiblity to xp. so the (well running 097demo/dll...) can not directly integrated into our client. Therefore i always move your code (.h and .cpp) in my project. remove all '_QuickGUIExport' from the code and fixing the bugs (on my side).
I havent followed the linux thread. but i think in the further it might be bette to have 3 projects for quickgui. 1. vs2005 2. vs2003 3. linux i don't think that the runtime changes from vs2005 to vs2008 are so heavy that there must be a fourth option of it.
The small improvement:
i added a bool like the mGainFocusOnClick
if( !mWidgetContainingMouse->getDropEnabled() )
if( mWidgetContainingMouse != mActiveWidget )
eventHandled = true;
I havent tested it cause of the reason. (oh sweet a cool new function for me... lets migrate the from 96b to 97 cant take more than 5 minutes
The way i think how drag and drop can work 'for me' is that i set a flag to the widget which can send EVT_BTN_UP without former EVT_BTN_DOWN. using a new flag.