Jump to content

unbindkey help


boro

Recommended Posts

Posted

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 
) 

I'll help When I Can.

Posted

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 
) 

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

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 
) 

Omerta Roleplay

Posted

You're welcome.

@MADE: That code does the same as mine, just different method, but still, it's not "better".

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

@ Solidsnake14 :

Qustion, Shouldn't be not state in your code ? ( at the showCursor function )

" Keep Thinking Different . " - Steve Jops

--------------------

Don't send me PMs asking for help, I Won't reply !

Posted
@ 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 ); 

Posted

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 ?

" Keep Thinking Different . " - Steve Jops

--------------------

Don't send me PMs asking for help, I Won't reply !

Posted

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.

Posted

Oh, I got it now .

Thank you .

" Keep Thinking Different . " - Steve Jops

--------------------

Don't send me PMs asking for help, I Won't reply !

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...