• Print

Author Topic: sb_row centering?  (Read 4710 times)

0 Members and 1 Guest are viewing this topic.

Offline iViscosity

  • Respected Community Member
  • Hero Member
  • *****
  • Posts: 803
  • Karma: 58
sb_row centering?
« on: October 04, 2016, 04:41:43 pm »
Code: Lua
  1. function PANEL:DoRightClick()
  2.  
  3.  
  4.    local menu = DermaMenu()
  5.    menu.Player = self:GetPlayer()
  6.  
  7.  
  8.    local close = hook.Call( "TTTScoreboardMenu", nil, menu )
  9.    if close then menu:Remove() return end
  10.  
  11.  
  12.     local ply = self.Player
  13.     local caller = LocalPlayer()
  14.    
  15.         if caller:CheckGroup( "user" ) then
  16.          
  17.         surface.PlaySound( "buttons/button9.wav" )
  18.         local options = DermaMenu()
  19.  
  20.  
  21.         options:AddOption( "Profile", function()
  22.          
  23.                 ply:ShowProfile()
  24.                 surface.PlaySound("buttons/button9.wav")
  25.  
  26.  
  27.       end )
  28.  
  29.  
  30.         options:AddSpacer()
  31.          
  32.         options:AddOption( "Copy SteamID", function()
  33.            
  34.                 SetClipboardText( ply:SteamID() )
  35.                 surface.PlaySound( "buttons/button9.wav" )
  36.  
  37.  
  38.         end )
  39.  
  40.  
  41.         end
  42.  
  43.  
  44.         menu:Open()
  45.    end


I'm using that code to, obviously, bring up a DermaMenu that will show (1) Profile and (2) Copy SteamID. Now, testing those as it is right now works just fine, but I was wondering how I could make the menu show up where the mouse is, instead of the top-left corner of the screen? I have no idea how :P
« Last Edit: October 05, 2016, 12:52:06 pm by iViscosity »
I'm iViscosity. I like gaming and programming. Need some help? Shoot me PM.

Offline roastchicken

  • Respected Community Member
  • Sr. Member
  • *****
  • Posts: 476
  • Karma: 84
  • I write code
Re: sb_row centering?
« Reply #1 on: October 04, 2016, 06:09:18 pm »
You should add the options before opening it. menu:Open() should probably be the last thing you do in that function. Not sure if this will resolve your problem, but it's worth a try and it's good to do anyways.
Give a man some code and you help him for a day; teach a man to code and you help him for a lifetime.

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: sb_row centering?
« Reply #2 on: October 04, 2016, 07:10:33 pm »
Having no derma experience, I'm reasonably sure you'd include this - gui.MousePos
As for getting the top right corner of the menu there, and checking to make sure the mouse was in a position that wouldn't draw everyhing off the screen (yet, still appear near it to closest edges and still show) is beyond my current time I have.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: sb_row centering?
« Reply #3 on: October 04, 2016, 07:16:51 pm »
Ok, i took 5 more minutes, found this.
No idea if it helps, but the raw panel menu open command takes co-ords.
DMenu:Open
However, your code may be taking or would ignore expected input.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline iViscosity

  • Respected Community Member
  • Hero Member
  • *****
  • Posts: 803
  • Karma: 58
Re: sb_row centering?
« Reply #4 on: October 05, 2016, 02:39:25 am »
Thanks both of you. I'll try out opening the menu last first to see if it automatically does it later today.
I'm iViscosity. I like gaming and programming. Need some help? Shoot me PM.

Offline iViscosity

  • Respected Community Member
  • Hero Member
  • *****
  • Posts: 803
  • Karma: 58
Re: sb_row centering?
« Reply #5 on: October 05, 2016, 12:49:31 pm »
Ok, i took 5 more minutes, found this.
No idea if it helps, but the raw panel menu open command takes co-ords.
DMenu:Open
However, your code may be taking or would ignore expected input.

I don't know how different they are, but it uses DermaMenu() not DMenu.
I'm iViscosity. I like gaming and programming. Need some help? Shoot me PM.

Offline Bytewave

  • Respected Community Member
  • Hero Member
  • *****
  • Posts: 718
  • Karma: 116
  • :)
    • My Homepage
Re: sb_row centering?
« Reply #6 on: October 05, 2016, 03:22:49 pm »
I don't know how different they are, but it uses DermaMenu() not DMenu.
DMenu == DermaMenu
bw81@ulysses-forums ~ % whoami
Homepage

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: sb_row centering?
« Reply #7 on: October 05, 2016, 05:29:30 pm »
The first few words your link to DermaMenu even says " Description - Creates a DMenu "
So, dang it, just try tinkering. Add coordinates to open() like I linked.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

  • Print