16
SCI Syntax Help / Re: SCI0: right click to look like in QFG2
« on: March 18, 2024, 11:49:08 AM »
Here's what I do in Betrayed Alliance. It might not be the most efficient code, but it works for me well enough.
First I will make a procedure:
First I will make a procedure:
Code: [Select]
(procedure (checkEvent pEvent x1 x2 y1 y2)
(if
(and
(> (pEvent x?) x1)
(< (pEvent x?) x2)
(> (pEvent y?) y1)
(< (pEvent y?) y2)
)
(return TRUE)
else
(return FALSE)
)
)I will reference this procedure in the handleEvent method in this way:Code: [Select]
(if (== (pEvent type?) evMOUSEBUTTON)
(if (& (pEvent modifiers?) emRIGHT_BUTTON)
(if (checkEvent pEvent 92 123 65 117) ; clicked within the box of these coordinates
(PrintOther 18 6)
) You can also reference the coordinates of a view this way:Code: [Select]
(checkEvent pEvent (mapItem nsLeft?) (mapItem nsRight?) (mapItem nsTop?) (mapItem nsBottom?))
(PrintOther 18 24)
)You can also check to see if the click happened on a control color:Code: [Select]
(if
(== ctlGREY (OnControl ocSPECIAL (pEvent x?) (pEvent y?)))
(PrintOther 18 77)
)Or on a priority color:Code: [Select]
(if
(== ctlYELLOW (OnControl ocPRIORITY (pEvent x?) (pEvent y?)))
(PrintOther 18 78)
)This is what works for me. Perhaps when I start a new project, I'll look into having something more global, but this does the trick for now,