boro Posted May 11, 2013 Share Posted May 11, 2013 Hi all please help i try make gui, it work fine but i dont know how to set unbindkey This work only for open bindKey('F4','down', function ( ) guiSetVisible (GUIEditor_Window[1],true) showCursor (true) end ) And next time i try this and guy dont open why ? please help bindKey('F4','down', function ( ) guiSetVisible (GUIEditor_Window[1],true) showCursor (true) end unbindKey('F4','down', function ( ) guiSetVisible (GUIEditor_Window[1],false) showCursor (false) end ) Link to comment
Castillo Posted May 11, 2013 Share Posted May 11, 2013 Because that doesn't make any sense, you don't want to unbind, you want to hide the window when it's open. bindKey ( 'F4', 'down', function ( ) local state = ( not guiGetVisible ( GUIEditor_Window[1] ) ) guiSetVisible ( GUIEditor_Window[1], state ) showCursor ( state ) end ) Link to comment
WASSIm. Posted May 11, 2013 Share Posted May 11, 2013 try this bindKey("F4", "down", function () local IsWindowVisible = guiGetVisible(GUIEditor_Window[1]) if (IsWindowVisible == true) then guiSetVisible(GUIEditor_Window[1], false) showCursor(false) end if (IsWindowVisible == false) then guiSetVisible(GUIEditor_Window[1], true) showCursor(true) end end ) Link to comment
xXMADEXx Posted May 11, 2013 Share Posted May 11, 2013 This way would probably work a little better, just a little less messy: function windowAdjusting() guiSetVisible(GUIEditor_Window[1], not guiGetVisible(GUIEditor_Window[1])) showCursor(guiGetVisible(GUIEditor_Window[1])) end bindKey("F4","down",windowAdjusting) Link to comment
Castillo Posted May 12, 2013 Share Posted May 12, 2013 You're welcome. @MADE: That code does the same as mine, just different method, but still, it's not "better". Link to comment
PaiN^ Posted May 12, 2013 Share Posted May 12, 2013 @ Solidsnake14 : Qustion, Shouldn't be not state in your code ? ( at the showCursor function ) Link to comment
50p Posted May 12, 2013 Share Posted May 12, 2013 @ Solidsnake14 :Qustion, Shouldn't be not state in your code ? ( at the showCursor function ) There is not already when defining the variable. The problem here is that you can't unbind anonymous functions. You can do what {RoG}xXMADEXx suggested. This way you can use: unbindKey( "F4", "down", windowAdjusting ); Link to comment
PaiN^ Posted May 12, 2013 Share Posted May 12, 2013 What i ment is in {RoG}xXMADEXx code the showCursor function's value is set to guiGetVisible, But if you use the state variable ( which as you said Already have not when defining in it. ) Then {RoG}xXMADEXx code should look like this : function windowAdjusting() guiSetVisible(GUIEditor_Window[1], not guiGetVisible(GUIEditor_Window[1])) showCursor(not guiGetVisible(GUIEditor_Window[1])) end bindKey("F4","down",windowAdjusting) But i know that this will revers the function, so how can it be correct ? Link to comment
50p Posted May 12, 2013 Share Posted May 12, 2013 I'm not talking about his code but his method. You have to declare the function first and then bind it to a key so then you can unbind it. His code will work properly since first he's setting gui visibility to opposite visibility state (if it's visible, not will make the return value: false = invisible), then he's getting the gui element visibility state to set the same to cursor. So, eg: hiding the gui first, then using the same visibility (guiGetVisible @ line 3) to cursor so hiding the cursor too. 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