35 views
in GUI Development by

Good Day to All.
I am trying to do a mouse type operation in my gui. it will be controlled later with device integrated hard buttons.

My arrow position changes with B1-B2-B3-B4 no problem with this.

i need to simulate click operation on button B5 where the arrow is last present.

For example after positioning the arrow on top of the Test Button i need to be able to click on it.

1 Answer

+1 vote
by
 
Best answer

Hello,

i need to simulate click operation on button B5 where the arrow is last present. For example after positioning the arrow on top of the Test Button i need to be able to click on it.

I don't really understand this application case. What do you mean with "where the arrow is last present"?

Embedded Wizard supports hardware buttons and keyboards natively. Please see Handling keyboard events. This permits you also to test the application in Prototyper by using dedicated keyboard keys. In other words, the hard buttons are represented by keyboard keys. Maybe this is a better solution for your application case?

Best regards

Paul Banach

by
Hello

we are trying to make an analog joystick. the analog joystick will control the arrow movement. at the moment it is not connected so i am simulating the arrow movement with buttons 1-2-3-4. while moving on the page if i stop on a keypad or a scrollbar or another button i need to press it. at the moment any press operation can be done by simple touch event but i need to make the press operation with a hardware button. just like how a real mouse cursor operates.

the arrow will behave like a mouse cursor.

here is a video

https://drive.google.com/file/d/1rGx84Zo8XqL8ajTbway2QvMijQofLL4K/view?usp=sharing

since arrows last position is on Button labeled Test when i press B5 i need Test button to react like how it reacts to a mouse cursor click.
by

Hello,

thank you for the explanation and the video. It is clear now. The arrow represents the mouse pointer and you want to simulate a mouse DOWN and UP events for the corresponding position.

To do this you need to understand how real touch/mouse events are fed into the GUI application. This is achieved by the methods DriveCursorHitting and DriveCursorMovement. These methods are accessible within the Application component. Thus, to feed a simulated mouse event execute following code in context of the Application class:

// Get the position of the 'mouse pointer' image
var point pos = ArrowImage.Bounds.origin;

// Simulate the DOWN/UP event pair for the given position
DriveCursorHitting( true,  0, pos );
DriveCursorHitting( false, 0, pos );

In your case you would execute the code when the user activates the B5 button. The above code feeds the DOWN/UP events only. If necessary, you can also use the method DriveCursorMovement() to feed drag events generated between the DOWN and the UP event.

Does it help you further?

Best regards

Paul Banach

by
Hello. Thank you very much.
Yes it is what i was looking for. Great explanation.
Could you share an example for drag event as well if possible. For the next step i think we will be using this mouse to drag some scroll bars.
by

Hello,

Could you share an example for drag event as well if possible.

in principle, when the position of the mouse pointer (arrow) changes, you execute following code to provide this new position to GUI. This will generate the appropriate drag events:

// Get the position of the 'mouse pointer' image
var point pos = ArrowImage.Bounds.origin;

// Simulate the drag event to the given position
DriveCursorMovement( pos );

See also the documentation for the methods DriveCursorHitting and DriveCursorMovement

Best regards

Paul Banach

Ask Embedded Wizard

Welcome to the question and answer site for Embedded Wizard users and UI developers.

Ask your question and receive answers from the Embedded Wizard support team or from other members of the community!

Embedded Wizard Website | Privacy Policy | Imprint

...