Hotspots without Hotspots Thread last updated on 2004-04-25 14:17:35

Posted by member 12798 on 2004-01-16 17:32:28

This is a simple script which provides hotspot functionality. It simply checks if the mouse is located inside a certain area. Nothing spectacular, especially not the code ... however, maybe somebody finds it helpful. :)
It uses mzscript's internal variables mousex and mousey and a timer to run the check in certain intervals.

It doesn't work "out of the box", but you simply need to modify/specify some settings/variables.


The first thing is, we have two modules. By default, Module1 is displayed. We want Module2 to show up at the same location when we enter Module1. So we set up Module1 to execute a bang on the OnEnter event.
<Module1>OnEnter !Show<Module2>

!Show<Module2> is a custom bang which hides Module1, shows Module2 and launches a timer. This timer calls the script which checks the mouse position every n seconds.
Once the mouse leaves the defined area (see below), module visibility returns to default.
*Script bang !Show<Module2>
*Script exec !<Module1>Hide
*Script exec !<Module2>Show
*Script exec !TimerAdd ATimer <n> !CheckIfMouseOn<Module2>
*Script exec !TimerStart ATimer
*Script ~bang

*Script bang !Hide<Module2>
*Script exec !<Module2>Hide
*Script exec !<Module1>Show
*Script ~bang


Now we set up the !CheckIfMouseOn<Module2> Bang called by the timer, and the coordinates of the area in it.
The rest of the Bang calles the actual Mouse Position Evaluation Routine (MPER (c)) and then the !Hide<Module2> Bang if the mouse has left the specified area.
*Script bang !CheckIfMouseOn<Module2>
*Script exec !execute [!varset x1 $<Module2>X$][!varset x2 $<Module2>X+<Module2>Width$][!varset y1 $<Module2>Y$][!varset y2 $<Module2>Y+<Module2>Height$]
*Script exec !CheckIfMouseOnArea
*Script gotoif ("%{NotOnArea}" = "true") l_NotOnArea
*Script exit
*Script label l_NotOnArea
*Script exec !Hide<Module2>
*Script ~bang

At last, the following evaluates if the mouse is inside the specified area. If so, the timer is removed, if not, it is restarted and will repeat the whole procedure.
*Script bang !CheckIfMouseOnArea
*Script exec !execute [!varint x1][!varint x2][!varint y1][!varint y2]
*Script gotoif ("%{mousex}" < "%{x1}") l_NotOnArea
*Script gotoif ("%{mousex}" >= "%{x2}") l_NotOnArea
*Script gotoif ("%{mousey}" < "%{y1}") l_NotOnArea
*Script gotoif ("%{mousey}" >= "%{y2}") l_NotOnArea
*Script exec !execute [!TimerKill ATimer][!TimerStart ATimer]
*Script exec !varset NotOnArea false
*Script exit
*Script label l_NotOnArea
*Script exec !varset NotOnArea true
*Script exec !TimerRemove ATimer
*Script ~bang

That's it. Hope everything is made clear :)


Note #1: Now you ask, this is nothing but a complicately set up Hotspot?! - Well yes, indeed. But i used to have some problems with Hotspots sometimes not noticing the mouse leaving. So i created this one as a "safe" method ;)

Note #2: This one is dedicated to my girlfriend :P

Posted by member 12798 on 2004-01-16 17:50:05 link

problem solved, post still here :D

thanks doy

edit: edited about 10.000 times, some code lines look weird on my browser, dunno why. argh. :-$

Posted by member 7223 on 2004-01-17 21:08:46 link

I'm already using self-made hotspots like yours... :)

Posted by member 5669 on 2004-02-17 17:06:26 link

also, if you're already using xlabel, you can use its built in hotspot function... just a thought.

Posted by member 125450 on 2004-04-12 06:41:58 link

How do you use xlabel for hotspots?
I have two hotspot menues and would like to ditch as many modules as I can
*ckHotspot 0 -1 1 1 "!Desktopmenu" x=0 y=-28 left bottom" !None
*ckHotspot -1 0 1 1 "!Popup" x=-150 y=-28 right top" !None

Posted by member 144637 on 2004-04-25 13:04:24 link

Hmm..... I have a REALLY stupid question, but couldnt you just make a majic pink box, set the x and y, and TrueTRansparency, then have it load up what you want your hotspot to? Just Curious

Posted by member 37809 on 2004-04-25 14:17:35 link

If it's truly transparent, then mousing over that transparent region will do nothing (unless whatever the cursor really is over does something).