Jump to content

Click outside GUI to close?


Recommended Posts

Posted

Hi! On some servers I noticed that they have a quick trick to close the GUI Windows - clicking outside.

How to do that, but without breaking my element-clicking system?

Posted

If MTA element tree works the way the developers say it does then this should hide all gui elements when you click outside GUI elements:

addEventHandler( "onClientClick", root, 
    function( btn ) 
        if btn == "left" then 
            guiSetVisible( root, false ); -- this should hide all the GUI visible 
        end 
    end 
) 

If you get an error message then you have to specify which GUI element (window) you want to hide.

Posted
If MTA element tree works the way the developers say it does then this should hide all gui elements when you click outside GUI elements:
addEventHandler( "onClientClick", root, 
    function( btn ) 
        if btn == "left" then 
            guiSetVisible( root, false ); -- this should hide all the GUI visible 
        end 
    end 
) 

If you get an error message then you have to specify which GUI element (window) you want to hide.

guiSetVisible( root, false );

Isn't "guiRoot" ?

Posted
as i understand you, u must use event onClientGUIClick, and check if your window isn't source.

If the window isn't source, it can be something else. The user can't click any GUI therefore can't raise onClientGUIClick event.

Posted

Haven't tested nor used it, but I think you mean onClientGUIBlur.

https://wiki.multitheftauto.com/wiki/OnClientGUIBlur

This event is triggered each time a GUI element looses input focus (mainly useful for windows, editboxes and memos but triggered for all GUI elements nevertheless).

When you click outside a window, it looses focus. When this event is triggered, you simply hide/destroy/disable/dowhateveryouwanttodowith the gui-stuff.

  • 1 month later...
Posted
Haven't tested nor used it, but I think you mean onClientGUIBlur.

https://wiki.multitheftauto.com/wiki/OnClientGUIBlur

This event is triggered each time a GUI element looses input focus (mainly useful for windows, editboxes and memos but triggered for all GUI elements nevertheless).

When you click outside a window, it looses focus. When this event is triggered, you simply hide/destroy/disable/dowhateveryouwanttodowith the gui-stuff.

It works only when client choose other window, not when he click somewhere outside.

Any other ideas?

Posted

something like that ..

  
addEventHandler("onClientGUIClick",root,function() 
       if ( guiGetVisible(myGui) == true and source ~= myGui ) then 
            guiSetVisible(myGui,false) 
       end 
end ) 
  

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...