[Home] [Downloads] [Search] [Help/forum]

Gammon Forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  General
. . -> [Subject]  Menu function / Alter size of the box and possibly location.
Home  |  Users  |  Search  |  FAQ
Register forum user name
Forgotten password?

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

You need to log onto the forum to reply or create new threads.

  [Refresh] Refresh page

Posted by Rhien   (13 posts)  [Biography] bio
Date Tue 05 Jun 2018 02:19 PM (UTC)
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).
[Go to top] top

Posted by Nick Gammon   Australia  (21,677 posts)  [Biography] 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

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)
    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
[Go to top] top

Posted by Rhien   (13 posts)  [Biography] bio
Date Reply #2 on Thu 07 Jun 2018 07:47 PM (UTC)
Thank you Nick! You're helpful as always and it is appreciated.
[Go to top] 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.


You need to log onto the forum to reply or create new threads.

  [Refresh] Refresh page

Go to topic:           Search the forum

[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

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


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at FutureQuest]