Jusonex Posted October 14, 2011 Share Posted October 14, 2011 Hey guys, I've got a little problem. I created a GUI image like this: editor.main.imgSaveExit = guiCreateStaticImage(X, Y+240, 72, 72, "images/save_exit.png", false) and I also use a clicksystem on objects/vehicles. But the problem is, if I click on this image, the object behind this image triggers onClientClick, too. How could I deny this? (if the player clicks on the image, onClientClick won't be triggered) Link to comment
Jusonex Posted October 14, 2011 Author Share Posted October 14, 2011 No. editor.main.imgOther = guiCreateStaticImage(X, Y+160, 72, 72, "images/other.png", false) addEventHandler("onClientGUIClick", editor.main.imgOther, editor.main.clickImage, false) That's already good. It's part of an own map editor. This image is a menu item. For example I place an object somewhere in the map. Now I want to select it to move it or whatever. But on the same position is an object in the 3D world. If I click on this menu item, onClientClick (attached to the object) will be triggered, but onClientGUIClick (attached to the gui image), too. Link to comment
50p Posted October 19, 2011 Share Posted October 19, 2011 Cancel the onClientClick event if the click position is in the boundary of the button. local imgPos = { guiGetPosition( editor.main.imgOther, false ) }; local imgSize = { guiGetSize( editor.main.imgOther, false ) }; if ( clickedX > imgPos[ 1 ] and clickedX < imgPos[ 1 ] + imgSize[ 1 ] and clickedY > imgPos[ 2 ] and clickedY < imgPos[ 2 ] + imgSize[ 2 ] ) then cancelEvent( ); end This could be a useful for collision detection (only for rectangular shapes) function that you get in ActionScript (hitTest). Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now