GUI: Left Click & Right Click on a image ?

Irrlicht.Net is no longer developed or supported, Irrlicht.Net Cross Platform is a much more complete wrapper. Please ask your C# related questions on their forums first.
Locked
Nezumi
Posts: 15
Joined: Fri Sep 30, 2005 9:42 pm

GUI: Left Click & Right Click on a image ?

Post by Nezumi »

Image



I want to get right click and left click on a GUI Image... In order to create custum GUI windows.
Right click: Close
Left click : Move

someone can help me? thanks !! :D
Martins

Post by Martins »

Hello,

I don't have any code for this, but some ideas.
I see that every IGUIElement in C++ implementation is IEventReceiver,
which means all elements should have overridable OnEvent(), where
you could check if user clikced withing area of the control.
But unfortunately .NET implementation is poor and lacks this.

Another option would be to GetElementFromPoint on the root element,
something like:

Code: Select all

Position2D pos = new Position2D(x,y);
device.GUIEnvironment.RootGUIElement.GetElementFromPoint(pos);
But you have to check if that element is visible or not covered by another
child element.
RapchikProgrammer
Posts: 279
Joined: Fri Dec 24, 2004 6:37 pm

Post by RapchikProgrammer »

Use the onkey event to get the clicks. Then check if cursor.x and cursor.y is in the area of the image. Then if you want to move, get the difference between the positionx of the image and the current cursorx and the positiony of the image and the current cursory. Then check for left-click up event. At that point take the cursor x and cursor y and deduce the previous distance calculated previously. The distance stuff is done so that the image movement is like windows drag command.

Just the theory make the code yourself.
Locked