My question is if there exist anything similar to Frame:MakePopup() but hides the cursor instead of making it "popup".
Use Panel:MakePopup() and then just hide the cursor using [url]http://wiki.garrysmod.com/page/Panel/SetCursor[/url]
[QUOTE=Moosicorn;50708399]Use Panel:MakePopup() and then just hide the cursor using [url]http://wiki.garrysmod.com/page/Panel/SetCursor[/url][/QUOTE]
Okay. I've already tried that but it didn't work. Should I type panel:SetCursor("none") then?
[QUOTE=Jompe...;50708444]Okay. I've already tried that but it didn't work. Should I type panel:SetCursor("none") then?[/QUOTE]
probably
Sorry for being confusing. What I want to do is being able to hide the cursor so the player can move and look around again but still have the Frame visible on the screen.
Do not call MakePopup then.
[QUOTE=Robotboy655;50708791]Do not call MakePopup then.[/QUOTE]
I'll try to explain again.. I want a function so I can toggle the cursor being visible, like you can in DarkRP by pressing F3.
gui.EnableScreenClicker(true/false)?
Oh, I get what you want to do. You mean that when you press a key the user is able to move with the panel still open. Try this:
[CODE]
local frame = vgui.Create('DFrame')
frame:SetSize(500,500)
frame:Center()
frame:MakePopup()
function frame:Think(w,h)
if input.IsKeyDown( KEY_D ) then
self:SetMouseInputEnabled( false )
self:SetKeyboardInputEnabled( false )
else
self:SetMouseInputEnabled( true )
self:SetKeyboardInputEnabled( true )
end
end
[/CODE]
For some reason the mouse seems to stop moving when you move it outside the panel though
EDIT: What's wrong with this code? He said this:
[QUOTE=Jompe...;50708834]I'll try to explain again.. I want a function so I can toggle the cursor being visible, like you can in DarkRP by pressing F3.[/QUOTE]
I guessed that by toggling the cursor he meant that he wants to be able to toggle whether or not the user is interacting with the panel, which obviously needs a cursor so you can see what you're clicking on. So, the code above lets you enable or disable interaction with the panel by holding D, which lets the user move around while the panel is still open on screen, while their mouse isn't being shown. Makes sense to me.
[QUOTE=Jompe...;50708620]Sorry for being confusing. What I want to do is being able to hide the cursor so the player can move and look around again but still have the Frame visible on the screen.[/QUOTE]
[QUOTE=TheMafieuur;50708594][URL="http://wiki.garrysmod.com/page/Panel/Show"]http://wiki.garrysmod.com/page/Panel/Show[/URL][/QUOTE]
[QUOTE=man with hat;50711181]-snip-[/QUOTE]
There's no point in calling Panel:Show when panels are already shown by default, that won't help anything. He never said he wanted to hide the panel either if that's what you were thinking. Also, thanks for rating me dumb for trying to give an actually helpful answer rather than reposting something already said, which he already saw and didn't find helpful.
[QUOTE=MPan1;50711435]There's no point in calling Panel:Show when panels are already shown by default, that won't help anything. He never said he wanted to hide the panel either if that's what you were thinking. Also, thanks for rating me dumb for trying to give an actually helpful answer rather than reposting something already said, which he already saw and didn't find helpful.[/QUOTE]
He never said he wanted to hide the panel. He never said he [I][B]didn't[/B][/I] want to hide the panel either. He didn't provide code. If he wants to hide the panel and show it at a different time, then obviously he's going to need to call Show if he doesn't want the mouse captured. If he isn't hiding the panel, it's not like calling Show is committing some sin, no?
He asked how how he can do this
[quote]hide the cursor so the player can move and look around again but still have the Frame visible on the screen[/quote]
Show does exactly that. He didn't acknowledge the post that gave it to him, so I'm quoting it.
And stop taking ratings like they're some personal attack against you. I rated you dumb cause Show is the solution and I don't even know what your code is trying to do.
Well, I took what he said to mean that he wants to make the panel a popup, but he also wants to be able to toggle whether or not the player can move while the panel is still a popup on screen, which is what my code does.
If you press D, then mouse and keyboard input are disabled, letting the player move around while the panel is still visible on the screen...
[QUOTE=Jompe...;50708620]Sorry for being confusing. What I want to do is being able to hide the cursor so the player can move and look around again but still have the Frame visible on the screen.[/QUOTE]
But if you release D, then it re-enables mouse and keyboard input, letting the user interact with the panel again with the cursor visible...
[QUOTE=Jompe...;50708834]I'll try to explain again.. I want a function so I can toggle the cursor being visible, like you can in DarkRP by pressing F3.[/QUOTE]
Anyway, hard to tell what the OP wants, we both could be wrong
[QUOTE=NiandraLades;50708929]gui.EnableScreenClicker(true/false)?[/QUOTE]
Thank you to everyone, this solved my issue.
Sorry, you need to Log In to post a reply to this thread.