Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ General ➜ Menu function / Alter size of the box and possibly location.

Menu function / Alter size of the box and possibly location.

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Rhien   (13 posts)  Bio
Date Tue 05 Jun 2018 02:19 PM (UTC)
Message
I'm using the Menu function to display a list of locations which then input the directions when one is selected (the items are tailored by character which is cool).

However, the menu box seems to be of static size and the last maybe 20 pixels of the box go below the MushClient window. Is there a way to:

1.) Make the box bigger.
2.) Perhaps adjust the coordinates (which, if the box could be made bigger, I could then pull the top of it up so that is all displays on the screen).
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #1 on Tue 05 Jun 2018 09:21 PM (UTC)

Amended on Tue 05 Jun 2018 09:36 PM (UTC) by Nick Gammon

Message
You have more flexibility with a "Miniwindow" menu. This example code, which you can put in your script file and run on when you connect, creates a gray bar which is an area you can click in, above the input box, and if you do it shows a menu.


local MENU_HEIGHT = 20

win = "MyMenu_" .. GetPluginID ()
WindowCreate (win, 0, 0, GetInfo (281), MENU_HEIGHT, miniwin.pos_bottom_left, 0, ColourNameToRGB("gray"))  -- create window
WindowShow (win,  true)  -- show it 

WindowFont (win, "f", "Arial", 10)
WindowText (win, "f", "Movement menu", 5, 0, 0, 0, ColourNameToRGB("white")) 

TextRectangle(0, 0, 0, -MENU_HEIGHT,
              0,  -- BorderOffset, 
              0,  -- BorderColour, 
              0,  -- BorderWidth, 
              ColourNameToRGB ("gray"),  -- OutsideFillColour, 
              miniwin.brush_solid) -- OutsideFillStyle (solid)

function MenuMouseup (flags, hotspot_id)
  local Items = "Village | Town Hall | Butcher | Grocer | Swamp | Armourer | Quest Hub"
  -- ~LB means put menu on left and with bottom where the mouse is
  local result = WindowMenu (win, 
                  WindowInfo (win, 14), -- mouse-click position (X)
                  WindowInfo (win, 15), -- mouse-click position (Y)
                  "~LB" .. Items)
  if result ~= "" then
    print ("You entered: ", result)
  else
    print ("Cancelled")
  end -- if
end -- MenuMouseup

WindowAddHotspot(win, "hs1",  
                 0, 0, 0, 0,   -- rectangle
                 "",  -- mouseover
                 "",  -- cancelmouseover
                 "",  -- mousedown
                 "",  -- cancelmousedown
                 "MenuMouseup",           -- mouse-up handler
                 "Movement menu",         -- tooltip text
                 miniwin.cursor_hand,     -- hand cursor
                 0)                       -- flags


The miniwindow menus allow you to position them relative to the cursor, that is, top, bottom, left, right, and so I put the menu bottom where the cursor is.

As well as clicking on it, you could use the the gray bar for displaying something like a status display (eg. HP, mana), the current room name, current exits, or something like that. For example, the words "Movement menu" in the example above could dynamically be changed to reflect something based on a trigger which fires on change of room, change of prompt, and so on (clear the existing text first with a call to WindowRectOp).

The TextRectangle function call stops the output text from being hidden underneath the bar (it shrinks the output text area in other words).

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Rhien   (13 posts)  Bio
Date Reply #2 on Thu 07 Jun 2018 07:47 PM (UTC)
Message
Thank you Nick! You're helpful as always and it is appreciated.
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


9,768 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.