Win32 - Fullscreen popup menu temperamental activation - c++

Using C++ in VS2008, I'm at the beginnings of a DirectX program which can so far display a token image and flip between fullscreen and windowed mode with no problems.
It has a menu bar, which is invisible as expected in fullscreen mode. The ALT key could still activate this menu in fullscreen, but it was very clumsy since its items weren't visible until highlighted, and even then it only responded to about 1 in 5 presses of the ALT key.
So I decided to implement a popup menu instead, that responds to the right mouse button. My problem is that this popup menu is also temperamental in fullscreen mode. It also plays with the custom cursor I am using.
The wrong behaviour is defined as follows:
1· A right click anywhere will active the popup menu, but also deactive the custom cursor and replace it with the system default.
2· Once the menu is visible, RIGHT-clicking outside of the menu will deactive it, but this leaves the default cursor on. However, right-clicking again will activate the menu again, and this continues perfectly if not for the missing custom cursor.
3· Once the menu is visible, LEFT-clicking outside of the menu will deactivate it, and this displays the custom cursor again. Now it gets a bit more messy because now:
3a· If I right-click, it will return to step 1. Menu on + cursor off.
3b· If I left-click a second time (as if I am gaining focus or something), then right-click, will will activate the default cursor but NOT active the menu (as if I half did and half didn't regain focus or something). Menu off + cursor off.
3c· If I move the mouse and then right-click, it will do one of the above. Step 1 or step 3b. Menu on + cursor off, or menu off + cursor off. Frustrating.
4· Most obvious, if step 3b occurs (menu off + cursor off), the user can flip the custom cursor on and off forever. Left click on, right click off. Not only does the menu never appear, but this is simply not what I want a user to be seeing in my program... the cursor changing for no reason.
I imagine the cursor changing is to do with the menu itself taking focus or something like that. I would like that to be avoided if possible, but the real problem is why is the menu activation temperamental in the first place?
My code for the popup menu is:
case WM_RBUTTONDOWN:
cout << "Right button in fullscreen" << endl;
TrackPopupMenu(GetSubMenu(g_menu,0), TPM_LEFTALIGN|TPM_HORPOSANIMATION,
30, 30, 0, g_parentWindow, NULL);
// SetActiveWindow(g_parentWindow); // Makes no difference.
// SetForegroundWindow(g_parentWindow); // Makes no difference.
break;
One more thing. If I use F3 to active the menu instead, absolutely nothing happens.
Problem 1: Can I make the menu activate reliably?
Problem 2: Can I stop the cursor from changing?
Problem 3: Why does a key command not work?
Thanks for the read. Any ideas?

you can use this little function to set the cursor back to your customize cursor SetCursor(CURSOR_ID); you can add this in WM_RBUTTONDOWN

Related

IntelliJ dialog focus

Trying to control Android Studio by keyboard only, I do not know why, but when I focus "Cancel" button and press enter, it acts like I clicked on the default button (next tip is shown). The same scenario applies to WebStorm.
then I press Tab or right arrow (notice the blue glow around the button)
The solution, as LazyOne mentioned, is to use SPACE instead of ENTER.

How to remove cursor from editable QComboBox when I either press enter or click mouse outside its area?

I have a QComboBox which is made editable. When I type some text in it and press enter, it is performing its action. But the cursor still blinks in the text box. And even if by mistake I press any UP/DOWN key the item is changing.
How to remove this blinking cursor if I press enter or click mouse outside its area?
That is the standard behavior of a combo box, in Qt or in any other toolkit. If you want that cursor to stop blinking, then give the keyboard focus to another widget. You can call QWidget::setFocus() on another widget of your application. Also have a look at the general documentation about focus in Qt5, Keyboard Focus in Widgets, to get more input on keyboard focus.

Drag and drop a button using CCControlbutton

I am new to cocos2d-x and I am developing a game in x-code using cocos2d-x2.0.4. In my game I created a button using CCcontrolbutton. Now I want to drag my button to one place to another. I tried with all the CCControlEvents but it doesn't work. Now I want to know, is it possible to drag and drop a button using CCControlbutton. I pasted my code which I have used to create the button.
button1 = CCControlButton::create(CCScale9Sprite::create("7.png"));
button1->setAdjustBackgroundImage(false);
button1->setPosition( ccp(winwsize/6, winhsize/7) );
button1->addTargetWithActionForControlEvents(this, cccontrol_selector(plus::add),CCControlEventTouchDragOutside);
button1->addTargetWithActionForControlEvents(this, cccontrol_selector(plus::add),CCControlEventTouchDragInside);
this->addChild(button1, 4);
In add() I have given the code to enter next scene. But now it is entering while clicking the button. But i want while drag it to one position to another. If it is possible to drag a button using CCControlbutton then please give me some sample codes. Thanks.
The events CCControlEventTouchDragInside and CCControlEventTouchDragOutside are happening when the user's touch (his fingertip) is entering or leaving your button while already or still touching the touchscreen (or while the mouse button is still pressed while the mouse pointer moves).
You would need to observe the dragging process yourself. Starting with a click on your button, change the button's position while the user is dragging (to visualize the dragging process), and then call plus::add() when the dragging ends in your target area.

What could be the reason of twice tap (touch) to press onscreen button, that presses from single mouse click?

I must say first - I AM NOT THE PROG OWNER, I don't know how it works and etc, I just need an advice that I could give them.
The program is running on windows based tablet PC with windows 8.
There is some prog that uses OpenGL ES 2.0. It renders some buttons and displays those.
Those buttons can be pressed by mouse left button, but if you use sensor screen, you must tap that button twice for single press.
Shortly - some button displayed.
Mouse left button single click -> button pressed
Single finger tap -> button not pressed
Double finger tap -> button pressed.
I don't understand why that happens. Single tap should imitate single click... Weird.
Anyone have any ideas?
I am not sure about this, but I think this may have something to do with how the program checks if the button is pressed. (long long time ago in my C++ days) If it checks the coordinates on click event then there is a possibility that when you touch the button, it only registers the location of the press, and not the press itself. On the second touch the location is already on the button so the click event is true on that button.
Anyone with more insight please feel free to edit ;-)

Can I determine if mouse button is already pressed to change cursor?

I am enabling drag and drop for one control in my SL 5 OOB app.
However, when the user is dragging a file, the cursor is the "copy file' cursor everywhere over my app.
Can I determine if, when the cursor enters my app, the left mouse button is down, and change the cursor appropriately (droppable or not droppable)?
Thanks for any insights...