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 ➜ Hyperlink in Miniwindows

Hyperlink in Miniwindows

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


Posted by Quit   (16 posts)  Bio
Date Sat 02 May 2015 06:47 PM (UTC)
Message
Hi

Can I have Hyperlink in miniwindows ?

When I try it, it writes in the main window and not in the miniwindow

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<muclient>
<plugin
   name="killlist"
   author="Me"
   id="c1c2a2e0907cd424a56863be"
   language="Lua"
   purpose="Shows area to level in"
   save_state="y"
   date_written="2010-05-02 15:35:51"
   requires="4.51"
   version="1.0"
   >
<description trim="y">
<![CDATA[
Type "killlist" to a miniwindow with areas.
]]>
</description>

</plugin>

<!--  Aliases  -->

<aliases>
  <alias
   match="killlist"
   enabled="y"
   send_to="12"
   sequence="100"
  >
<send>
  WindowCreate (win, 
                 100, 100, 300, 100,
                 windowinfo.window_mode,   
                 windowinfo.window_flags,
                 ColourNameToRGB "#000000")
                   
  WindowRectOp (win, 5, 0, 0, 0, 0, 5, 15 + 0x1000) -- draw border
  
  movewindow.add_drag_handler (win, 0, 0, 0, 20) -- add the drag handler
  
  WindowText (win, font, "Kill Areas", 25, 5, 0, 0, ColourNameToRGB  "green")
  WindowText (win, font, "Jungles of Verume", 25, 25, 0, 0, ColourNameToRGB  "yellow")
  WindowText (win, font, "Seven Wonders", 25, 35, 0, 0, ColourNameToRGB  "yellow")
  
  Hyperlink ("runto Elemental Chaos", "Elemental Chaos", "Elemental Chaos", "ligthblue", "black", 0)
  
  WindowShow (win, true)

</send>
  </alias>
</aliases>

<!--  Script  -->
<script>
<![CDATA[

require "movewindow"  -- load the movewindow.lua module

win = GetPluginID () .. "_inventory"
font = "f"
function OnPluginInstall ()
  -- install the window movement handler, get back the window position
  windowinfo = movewindow.install (win, 6)  -- default to 6 (on top right)
  -- make window so I can grab the font info
  WindowCreate (win, 0, 0, 0, 0, 1, 0, 0)
  -- add the font                 
  WindowFont (win, font, "Lucida Console", 9)  
end -- OnPluginInstall

function OnPluginSaveState ()
  -- save window current location for next time  
  movewindow.save_state (win)
end -- function OnPluginSaveState

]]>
</script>
</muclient>
Top

Posted by Fiendish   USA  (2,534 posts)  Bio   Global Moderator
Date Reply #1 on Sat 02 May 2015 08:02 PM (UTC)
Message
Not trivially. You have to create a hotspot, which means you have to know where the text is and how big it is. Then you have to assign mouseover/click actions to the hotspot.

https://github.com/fiendish/aardwolfclientpackage
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #2 on Sat 02 May 2015 09:14 PM (UTC)
Message
There is an example here:

http://www.gammon.com.au/mushclient/mw_hotspots.htm

In a miniwindow you need to know where you are putting the text, so you know the first thing Fiendish mentioned. You can also find out its height and width. This gives you a rectangle. Make that rectangle into a hotspot and handle mouse-up in that hotspot.

- Nick Gammon

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

Posted by Quit   (16 posts)  Bio
Date Reply #3 on Sun 03 May 2015 08:35 AM (UTC)
Message
ok I think I got it, here is what I have and its working.

But do I really need to make a function for every mouseup
or can I transfer the roomid with it somehow ?

And is there a way to change the color of the WindowText when I mouse over ?

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<muclient>
<plugin
   name="killlist"
   author="Me"
   id="c1c2a2e0907cd424a56863be"
   language="Lua"
   purpose="Shows area to level in"
   save_state="y"
   date_written="2010-05-02 15:35:51"
   requires="4.51"
   version="1.0"
   >
<description trim="y">
<![CDATA[
Type "killlist" to a miniwindow with areas.
]]>
</description>

</plugin>

<!--  Aliases  -->

<aliases>
  <alias
   match="killlist"
   enabled="y"
   send_to="12"
   sequence="100"
  >
<send>
  WindowCreate (win, 
                 100, 100, 300, 100,
                 windowinfo.window_mode,   
                 windowinfo.window_flags,
                 ColourNameToRGB "#000000")
                   
  WindowRectOp (win, 5, 0, 0, 0, 0, 5, 15 + 0x1000) -- draw border
  
  movewindow.add_drag_handler (win, 0, 0, 0, 20) -- add the drag handler
  
  WindowText (win, font, "Kill Areas", 25, 5, 0, 0, ColourNameToRGB  "green")
  WindowText (win, font, "Jungles of Verume", 25, 25, 0, 0, ColourNameToRGB  "yellow")
  WindowText (win, font, "Seven Wonders", 25, 35, 0, 0, ColourNameToRGB  "yellow")
  
	WindowAddHotspot(win, "Verume",  
                 25, 25, 280, 35,   -- rectangle Left, Top, Right, Bottom
                 "", "", "", "", 
                 "mouseup", 
                 "Goto Jungle of Verume",  -- tooltip text
                 miniwin.cursor_hand, 0)  -- hand cursor
				 
	WindowAddHotspot(win, "wonders",  
                 25, 35, 280, 45,   -- rectangle Left, Top, Right, Bottom
                 "", "", "", "", 
                 "mouseup1", 
                 "Goto Seven Wonders",  -- tooltip text
                 miniwin.cursor_hand, 0)  -- hand cursor
				 
	function mouseup (flags, Verume)
		Execute ("mapper goto 30599")
	end -- mouseup
	
	function mouseup1 (flags, wonders)
		Execute ("mapper goto 32981")
	end -- mouseup
  
  WindowShow (win, true)

</send>
  </alias>
</aliases>

<!--  Script  -->
<script>
<![CDATA[

require "movewindow"  -- load the movewindow.lua module

win = GetPluginID () .. "_killlist"
font = "f"
function OnPluginInstall ()
  -- install the window movement handler, get back the window position
  windowinfo = movewindow.install (win, 6)  -- default to 6 (on top right)
  -- make window so I can grab the font info
  WindowCreate (win, 0, 0, 0, 0, 1, 0, 0)
  -- add the font                 
  WindowFont (win, font, "Lucida Console", 9)  
end -- OnPluginInstall

function OnPluginSaveState ()
  -- save window current location for next time  
  movewindow.save_state (win)
end -- function OnPluginSaveState

]]>
</script>
</muclient>
Top

Posted by Fiendish   USA  (2,534 posts)  Bio   Global Moderator
Date Reply #4 on Sun 03 May 2015 03:04 PM (UTC)
Message
Quit said:

But do I really need to make a function for every mouseup
or can I transfer the roomid with it somehow ?

You can embed the room id in the hotspot name.

Quote:

And is there a way to change the color of the WindowText when I mouse over ?

Yes, by drawing it again in a different color.

https://github.com/fiendish/aardwolfclientpackage
Top

Posted by Quit   (16 posts)  Bio
Date Reply #5 on Sun 03 May 2015 05:51 PM (UTC)
Message
I "kind" of got the color change to work, but it dose not look good, its like you can see the old color behind it and it will only update when there is some action to the mud.

Can you please give a example of the function with the room
id in it, I am not very good at function, yet :)

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<muclient>
<plugin
   name="KillArea"
   author="Quit"
   id="1257642da6518030a25c93c4"
   language="Lua"
   purpose="List Area to level in"
   date_written="2015-05-03 20:32:36"
   requires="4.97"
   version="1.0"
   >

</plugin>

<aliases>
  <alias
   match="killlist"
   enabled="y"
   send_to="12"
   sequence="100"
  >

<send>
  WindowCreate (win, 
                 100, 100, 300, 100,
                 windowinfo.window_mode,   
                 windowinfo.window_flags,
                 ColourNameToRGB "#000000")
                   
  WindowRectOp (win, 5, 0, 0, 0, 0, 5, 15 + 0x1000) -- draw border
  
  movewindow.add_drag_handler (win, 0, 0, 0, 20) -- add the drag handler
  
  WindowText (win, font, "Kill Areas", 25, 5, 0, 0, ColourNameToRGB  "green")
  WindowText (win, font, "Jungles of Verume", 25, 25, 0, 0, ColourNameToRGB  "yellow")
  WindowText (win, font, "Seven Wonders", 25, 35, 0, 0, ColourNameToRGB  "yellow")
  
	WindowAddHotspot(win, "Verume",  
                 25, 25, 280, 35,   -- rectangle Left, Top, Right, Bottom
                 "mouseover", "CancelMouseOver", "", "", 
                 "mouseup", 
                 "Goto Jungle of Verume",  -- tooltip text
                 miniwin.cursor_hand, 0)  -- hand cursor
				 
	WindowAddHotspot(win, "wonders",  
                 25, 35, 280, 45,   -- rectangle Left, Top, Right, Bottom
                 "mouseover1", "CancelMouseOver1", "", "", 
                 "mouseup1", 
                 "Goto Seven Wonders",  -- tooltip text
                 miniwin.cursor_hand, 0)  -- hand cursor
				 
	function mouseup (flags, Verume)
		Execute ("mapper goto 30599")
	end -- mouseup
	
	function mouseover (flags, Verume)
		WindowText (win, font, "Jungles of Verume", 25, 25, 0, 0, ColourNameToRGB  "blue")
	end -- mouseover
	
	function CancelMouseOver (flags, Verume)
		WindowText (win, font, "Jungles of Verume", 25, 25, 0, 0, ColourNameToRGB  "yellow")
	end -- CancelMouseOver
	
	function mouseup1 (flags, wonders)
		Execute ("mapper goto 32981")
	end -- mouseup1
	
	function mouseover1 (flags, wonders)
		WindowText (win, font, "Seven Wonders", 25, 35, 0, 0, ColourNameToRGB  "blue")
	end -- mouseover1
	
	function CancelMouseOver1 (flags, wonders)
		WindowText (win, font, "Seven Wonders", 25, 35, 0, 0, ColourNameToRGB  "yellow")
	end -- CancelMouseOver1
  
  WindowShow (win, true)

</send>
  </alias>
</aliases>

<!--  Script  -->
<script>
<![CDATA[

require "movewindow"  -- load the movewindow.lua module

win = GetPluginID () .. "_KillArea"
font = "f"
function OnPluginInstall ()
  -- install the window movement handler, get back the window position
  windowinfo = movewindow.install (win, 6)  -- default to 6 (on top right)
  -- make window so I can grab the font info
  WindowCreate (win, 0, 0, 0, 0, 1, 0, 0)
  -- add the font                 
  WindowFont (win, font, "Lucida Console", 9)  
end -- OnPluginInstall

function OnPluginSaveState ()
  -- save window current location for next time  
  movewindow.save_state (win)
end -- function OnPluginSaveState

]]>
</script>

<include name="constants.lua"/>

</muclient>
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #6 on Sun 03 May 2015 07:59 PM (UTC)
Message
See this for inspiration:

http://www.gammon.com.au/forum/?id=9664

That draws dozens of hyperlinks. In fact you might just be able to adapt it to display your "runto" links because all the text is in tables.

Quote:

it will only update when there is some action to the mud.


You need to call the Redraw function to get it to update the miniwindow.

- Nick Gammon

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

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #7 on Sun 03 May 2015 10:33 PM (UTC)

Amended on Tue 05 May 2015 05:37 AM (UTC) by Nick Gammon

Message
As soon as you find yourself copying and pasting virtually the same thing, many times, is a good time to think about making a function to save yourself a lot of work.

Here is your plugin reworked in such a way:


<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<muclient>
<plugin
   name="KillArea"
   author="Quit"
   id="1257642da6518030a25c93c4"
   language="Lua"
   purpose="List Area to level in"
   date_written="2015-05-03 20:32:36"
   requires="4.97"
   version="1.0"
   save_state="y"
   >

</plugin>

<aliases>
  <alias
   match="killlist"
   enabled="y"
   send_to="12"
   sequence="100"
  >

<send>
 
  WindowShow (win, true)

</send>
  </alias>
</aliases>

<!--  Script  -->
<script>
<![CDATA[

require "movewindow"  -- load the movewindow.lua module

win = GetPluginID () .. "_KillArea"
font = "f"

-----------------------------------------
-- one entry for each hyperlink you want drawn
-----------------------------------------
links = {
 { text = "Jungles of Verume", tip = "Goto Jungle of Verume", send = "mapper goto 30599" },
 { text = "Seven Wonders",     tip = "Goto Seven Wonders",    send = "mapper goto 32981" },

-- more here ...

 } -- end of links table

-----------------------------------------
-- draw hyperlink text in required colour
-----------------------------------------
function drawText (which, colour)
  Redraw ()
  return WindowText (win, font, which.text, which.x, which.y, 0, 0, ColourNameToRGB  (colour))
end -- drawText
 
-----------------------------------------
-- mouse up
-----------------------------------------
function mouseup_hyperlink (flags, hotspotid)
  Send (links [tonumber (hotspotid)].send)  
end -- mouseup_hyperlink

-----------------------------------------
-- mouse over
-----------------------------------------
function mouseover_hyperlink (flags, hotspotid)
  drawText (links [tonumber (hotspotid)], "blue")
end -- mouseover_hyperlink

-----------------------------------------
-- cancel mouse over
-----------------------------------------
function cancel_mouseover_hyperlink (flags, hotspotid)
  drawText (links [tonumber (hotspotid)], "yellow")
end -- cancel_mouseover_hyperlink

-----------------------------------------
-- mouse down
-----------------------------------------
function mousedown_hyperlink (flags, hotspotid)
  drawText (links [tonumber (hotspotid)], "white")
end -- mousedown_hyperlink

-----------------------------------------
-- cancel mouse down
-----------------------------------------
function cancel_mousedown_hyperlink (flags, hotspotid)
  drawText (links [tonumber (hotspotid)], "yellow")
end -- cancel_mousedown_hyperlink

-----------------------------------------
-- make one hyperlink at current x,y location
-----------------------------------------
function MakeHyperlink (item, which)
 
  -- remember current x and y in the links table
  which.x = x
  which.y = y
 
  width = drawText (which, "yellow")
 
  WindowAddHotspot (win, item, which.x, which.y, which.x + width, which.y + font_height, 
                    "mouseover_hyperlink", -- MouseOver 
                    "cancel_mouseover_hyperlink", -- CancelMouseOver 
                    "mousedown_hyperlink", -- MouseDown 
                    "cancel_mousedown_hyperlink", -- CancelMouseDown 
                    "mouseup_hyperlink", -- MouseUp 
                    which.tip, 
                    miniwin.cursor_hand,
                    0) --  Flag

  y = y + font_height

end -- MakeHyperlink

function OnPluginInstall ()
  -- install the window movement handler, get back the window position
  windowinfo = movewindow.install (win, miniwin.pos_top_right)  -- default to top right
  
  -- make window so I can grab the font info
  WindowCreate (win, 0, 0, 0, 0, miniwin.pos_top_right, 0, 0)
  
  -- add the font                 
  WindowFont (win, font, "Lucida Console", 9)  
  
  -- find its height
  font_height = WindowFontInfo (win, font, 1)  -- height

  -- position for first hyperlink  
  x = 10    -- all text indented this far in
  y = 25    -- first hyperlink this far down
                 
  maxTextWidth = 0
  
  -- find maximum width 
  for k, v in ipairs (links) do
    maxTextWidth = math.max (maxTextWidth, WindowTextWidth(win, font, v.text))
  end -- for
  
  -- make the proper window
  WindowCreate (win, 
               windowinfo.window_left, 
               windowinfo.window_top, 
               maxTextWidth + (x * 2), 
               y + (#links * font_height) + 5,
               windowinfo.window_mode,   
               windowinfo.window_flags,
               ColourNameToRGB "black")

  -- title background
  WindowRectOp (win, miniwin.rect_fill, 0, 0, 0, font_height + 5, ColourNameToRGB "gray", 0)
  
                 
  -- draw a border
  WindowRectOp (win, miniwin.rect_draw_edge, 0, 0, 0, 0, 
                miniwin.rect_edge_raised, 
                miniwin.rect_edge_at_all + miniwin.rect_option_softer_buttons) -- draw border
  
  movewindow.add_drag_handler (win, 0, 0, 0, font_height) -- add the drag handler

  -- first line
  WindowText (win, font, "Kill Areas", x, 5, 0, 0, ColourNameToRGB  "gainsboro")

  -- add all hyperlinks  
  for k, v in ipairs (links) do
    MakeHyperlink (k, v)
  end -- for
       
end -- OnPluginInstall

function OnPluginSaveState ()
  -- save window current location for next time  
  movewindow.save_state (win)
end -- function OnPluginSaveState

]]>
</script>

</muclient>


Now the only work you have is to change one table:


links = {
 { text = "Jungles of Verume", tip = "Goto Jungle of Verume", send = "mapper goto 30599" },
 { text = "Seven Wonders",     tip = "Goto Seven Wonders",    send = "mapper goto 32981" },

-- more here ...

 } -- end of links table


Much easier, don't you think?

[EDIT] Assorted enhancements added.

- Nick Gammon

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

Posted by Quit   (16 posts)  Bio
Date Reply #8 on Mon 04 May 2015 05:41 PM (UTC)
Message
wow don't know what to say, Thanks it just works.

I still have to learn about function, but I learn more and more every time I play with the muchclient.

Thanks again :)
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #9 on Tue 05 May 2015 05:38 AM (UTC)
Message
Glad you like it. :)

In the interests of demonstrating good coding, I've amended it (above) to have two enhancements:


  • The width of the window is now automatically calculated to fit whatever-it-is that is the longest text
  • The title line now has a background to make it look more like a title bar, and more obvious you can click and drag it

- Nick Gammon

www.gammon.com.au, www.mushclient.com
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.


26,302 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.