Page 1 of 1

[16 May 2010] LayerID?

Posted: Sat Jun 13, 2020 5:32 pm
by Tarzin
Note: This is an archived post that was originally sent to the Hollywood mailing list on Sun, 16 May 2010 18:40:09 +0200

Hello,

I've set many brushes on a windows but don't know which is layer number attribued to a brush. Is it possible to add some code which displays LayerID when moving over a brush, or a text (text displayed with textout)?

Thanks a lot for advance.

Tarzin

[16 May 2010] Re: LayerID?

Posted: Sat Jun 13, 2020 5:32 pm
by PEB
Note: This is an archived post that was originally sent to the Hollywood mailing list on Sun, 16 May 2010 20:05:31 -0000

Will GetLayerAtPos()---a new 4.7 function---do what you want?

[17 May 2010] Re: Re: LayerID?

Posted: Sat Jun 13, 2020 5:32 pm
by Tarzin
Note: This is an archived post that was originally sent to the Hollywood mailing list on Mon, 17 May 2010 20:32:36 +0200

Hello rev, :
Will GetLayerAtPos()---a new 4.7 function---do what you want?
Yes, seems to be the right functon.

I've tried this code without success

Code: Select all

; Function p_displayLAYERID
;
Function p_displayLAYERID(msg)
Switch (msg.action)
Case "OnMouseMove":
     numid=GetLayerAtPos (msg.x,msg.y)
     DebugPrint (msg.x,msg.y,numid)
EndSwitch
EndFunction

InstallEventHandler({OnMouseMove = p_afficheLAYERID})

Repeat
WaitEvent
Forever
Any idea what's wrong?

Another think: Is debugprint function working without compilation?

thanks!

Eric/Tarzin

[17 May 2010] Re: LayerID?

Posted: Sat Jun 13, 2020 5:32 pm
by PEB
Note: This is an archived post that was originally sent to the Hollywood mailing list on Mon, 17 May 2010 19:50:44 -0000

p_afficheLAYERID does not match up with p_displayLAYERID

[18 May 2010] Re: Re: LayerID?

Posted: Sat Jun 13, 2020 5:32 pm
by Tarzin
Note: This is an archived post that was originally sent to the Hollywood mailing list on Tue, 18 May 2010 07:12:29 +0200

no, that's because I've translated my code from french to english but function's name is the same in both cases.

[18 May 2010] Re: LayerID?

Posted: Sat Jun 13, 2020 5:32 pm
by PEB
Note: This is an archived post that was originally sent to the Hollywood mailing list on Tue, 18 May 2010 14:16:39 -0000

Well, try the following code:

Code: Select all

EnableLayers()

SetFillStyle(#FILLCOLOR)
Box(5, 5, 50, 50, #RED)
Box(55, 5, 50, 50, #BLUE)
Box(110, 5, 50, 50, #GREEN)

Function p_displayLAYERID(msg)
	Switch (msg.action)
		Case "OnMouseMove":
			numid=GetLayerAtPos (msg.x,msg.y)
			DebugPrint (msg.x,msg.y,numid)
		EndSwitch
EndFunction

InstallEventHandler({OnMouseMove=p_displayLAYERID})

Repeat
	WaitEvent
Forever
When your mouse is over the red box, the ID will be 1; when over the blue box, it will be 2; and when over the green box, it will be 3.

[18 May 2010] Re: Re: LayerID?

Posted: Sat Jun 13, 2020 5:32 pm
by Tarzin
Note: This is an archived post that was originally sent to the Hollywood mailing list on Tue, 18 May 2010 19:14:25 +0200

rev, thx!

Your code is working and I found what was wrong! I sent you a sample of my code. Real code was

Code: Select all

; Function p_displayLAYERID
  
Function p_displayLAYERID(msg)
Switch (msg.action)
Case "OnMouseMove":
         numid=GetLayerAtPos (msg.x,msg.y)
         DebugPrint (msg.x,msg.y,numid)
EndSwitch
EndFunction

InstallEventHandler({OnKeyDown = p_majEnreg},{OnMouseMove=p_displayLAYERID})

Repeat
WaitEvent
Forever
This is not working but if you change the line

Code: Select all

InstallEventHandler({OnKeyDown = p_majEnreg},{OnMouseMove=p_displayLAYERID})

with

InstallEventHandler({OnKeyDown = p_majEnreg})
InstallEventHandler({OnMouseMove=p_displayLAYERID})
It works, strange no??

Eric

[18 May 2010] Re: Re: LayerID?

Posted: Sat Jun 13, 2020 5:32 pm
by Tarzin
Note: This is an archived post that was originally sent to the Hollywood mailing list on Tue, 18 May 2010 19:20:16 +0200

pffff, what an idiot...

InstallEventHandler({OnKeyDown = p_majEnreg, OnMouseMove = p_displayLAYERID})

and all is working!

Eric