English Amiga Board

English Amiga Board (http://eab.abime.net/index.php)
-   Coders. AMOS (http://eab.abime.net/forumdisplay.php?f=119)
-   -   Highlighting Zones (http://eab.abime.net/showthread.php?t=90022)

ricky500 01 January 2018 08:35

Highlighting Zones
 
I'm looking for a way to high light text zones when the mouse is moved over it and then un-highlight it when the mouse moves off it. (Like how a hyper text link will change color when you move the mouse over it in a browser)

Dan 01 January 2018 10:57

Like this ?

PHP Code:

Screen Open 0,640,200,16,lowres Flash Off 
Reserve Zone 10
Dim LINK
(10,4) : Rem Link(x,0)=state/not used   x,1=x x,2=y x,3=x1 x,4=y1      
Dim LINKTEXT
$(10)

Reserve Zone 11

Double Buffer 
Bob Update Off 
Autoback 0

rem setting up zone

For X=1 To 10
   TXT
$="Text Zone"+Str$(X)
   
LINKTEXT$(X)=TXT$
   
   
LINK(X,0)=0
   LINK
(X,1)=10+(X*5)
   
LINK(X,2)=10+(X*8)
   
LINK(X,3)=LINK(X,1)+(Len(TXT$)*8) : Rem 8 means font width 
   LINK
(X,4)=LINK(X,2)+Rem 9 here is font height 8 1  

   Set Zone X
,LINK(X,1),LINK(X,2)-9 To LINK(X,3),LINK(X,4)-Rem -9 here adjust to how the text x,y,txtis rendered on y 

Next X

rem main loop
Repeat 
   Cls 
   MX
=X Mouse
   MY
=Y Mouse
   M
=Mouse Zone
   Ink 2
   Text 10
,9,"Zone Under cursor="+Str$(M)

rem draw text:
   For 
X=1 To 10
      Ink 2
      
If M=X Then Ink 4   rem if mouse is under zonedraw the text in red, else white will be drawn 
      Text LINK
(X,1),LINK(X,2),LINKTEXT$(X)
   
Next 
   
   Screen Swap 
Wait Vbl 
Until Mouse Key
=

For a bit faster version, without double buffering, add rem in front of :

PHP Code:

Double Buffer 
Bob Update Off 
Autoback 0

...

cls 

and change
PHP Code:

Text 0,9,"Zone Under cursor="+Str$(M

to

PHP Code:

Text 0,9,"Zone Under cursor="+Str$(M)+"  " 


ricky500 02 January 2018 00:15

Yes! Thanks. :-)


All times are GMT +2. The time now is 05:58.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2018, vBulletin Solutions Inc.

Page generated in 0.06192 seconds with 11 queries