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.
Related
I am interested in it because I need to drag the ScrolledWindow not with a scroll bar but with a mouse - press the mouse button and drag the window content (Dragging the area inside the ScrolledWindow). As I figured out it is possible with the help of enabling the check box (touch screen simulation) in the inspector, but the problem is that I need to enable this check box every time I run the application.
I want to create something like plugin or driver for mouse and extend right button mouse menu with movements. First of all, I want to create next feature:
1.user press right button and while button pressed move mouse up
2.will be shown a simple image with the scheme. arrow up and text "close"
3.when button released current window will be closed.
something similar was in old opera browser and it was very comfortable.
I try to find in googleб but I found how to do only for WPF or browser. I want to create global for the whole system with different configs. for example mouse, up in explorer will close the window and in visual studio, it will fire "Run"(f5).
I want to create this using C#. also I have basic knowledge in c++.
I will be grateful for help
I have a win32 dialog with a text label, a user box (which is going to be filled a control thats created on the fly) and two pushbuttons. The user box has the focus set to begin with.
Now, in the initdialog, when I create a new control and add it to the userbox rect on the dialog, I actually want the focus to be on the control first and then go to the two buttons on tabbing and then back to the control. I tried using SetWindowPos(hWnd,HWND_TOP,0,0,0,0,SWP_NOSIZE | SWP_NOMOVE); to achieve this. But no help. I tried calling SetFocus() on the new control. The, the focus is set on the control on init, but when tab is pressed it goes on to the buttons and doesn't come back to the control. The focus just shifts between the two pushbuttons.
Any idea how I can add this newly created control to the tab order ?
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 ;-)
I need to know if there is a code in c++ that allows to simulate a click, on a background window (if that's impossible, a foreground window will do fine), without moving the mouse.
I also need to click on specific coordinates, and drag an item to some other position (always without moving the mouse).
Example:
my mouse pointer is at (500,700),
but i need to left click at (100,150),
and drag to (700,300).
I need to be able to move my mouse pointer without affecting the program,
and the program must run correctly without moving, or locking, the mouse pointer.
If this action is impossible in c++, a VB code will be apreciated.
From a C++ Windows application, you can call Windows API directly by first finding the window using FindWindow that will give you the window handle you want, then finding the area within this window that you want to click. You can use API like GetWindowRect for this.
Finally, you can send this window, or an area within it, mouse messages using mouse_event function to cause the mouse to move, click, drag and let go at a new location.