home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fish 'n' More 2
/
fishmore-publicdomainlibraryvol.ii1991xetec.iso
/
dirs
/
popupmenu_422.lzh
/
PopUpMenu
/
Source
/
InputHandler.a
< prev
next >
Wrap
Text File
|
1990-12-31
|
4KB
|
145 lines
opt l+,c+,d+,y+
opt ow1+,ow2+,ow3+,ow4+,ow5+,ow6+
INCLUDE "exec/types.i"
INCLUDE "PopUpMenu.i"
QUALIFIERS EQU IEQUALIFIER_LSHIFT+IEQUALIFIER_RSHIFT+IEQUALIFIER_CONTROL+IEQUALIFIER_LALT+IEQUALIFIER_RALT+IEQUALIFIER_LCOMMAND+IEQUALIFIER_RCOMMAND+IEQUALIFIER_MIDBUTTON+IEQUALIFIER_LEFTBUTTON
FALSE EQU 0
TRUE EQU 1
xdef @PopUpHandler
xref _IntuitionBase
section text,code
@PopUpHandler: MOVEM.L D2/A2-A6,-(A7)
MOVEA.L A0,A3 *A3 = Events
MOVEA.L A1,A2 *A2 = MySignals
MOVEA.L A3,A4 *A4 = Event
SUB.L A5,A5 *A5 = LastEvent
MOVEA.L (AbsExecBase).W,A6
MOVE.W sd_Down(A2),D2
BEQ.B NoMoveSignal
* ------------ Tell the task we are living.
MOVEA.L (A2),A1 *sd_PopUpMenuTask
MOVE.L sd_MouseMovedSig(A2),D0
JSR _LVOSignal(A6)
* ------------ No more events ?
NoMoveSignal:
MoreEvents: MOVE.L A4,D0
BEQ.W Done
* ------------ Mouseevent ?
MOVEQ.L #IECLASS_RAWMOUSE,D0
CMP.B ie_Class(A4),D0
BNE.W KeepEvent * Don't care about this message.
MOVE.W ie_Code(A4),D1
* ------------ Is menubutton already pressed.
TST.W D2
BNE.B MouseIsDown * Yes
* ------------ Menubutton pressed ?
MOVEQ.L #MENUDOWN,D0
CMP.W D1,D0
BNE.B KeepEvent * No
* ------------ Is any qualifierkey also pressed ?
MOVE.W #QUALIFIERS,D0
AND.W ie_Qualifier(A4),D0
BNE.B KeepEvent * Yes
* ------------ Is any screen active ?
MOVEA.L _IntuitionBase,A1
MOVEA.L ib_ActiveScreen(A1),A0
MOVE.L A0,D0
BEQ.B KeepEvent * No
* ------------ Is the mouse in the titlebar ?
MOVE.B sc_BarHeight(A0),D0
EXT.W D0
CMP.W sc_MouseY(A0),D0
BGT.B KeepEvent * Yes
* ------------ Is any window active ?
MOVEA.L ib_ActiveWindow(A1),A0
MOVE.L A0,D0
BEQ.B KeepEvent * No
* ------------ Is any requester blocking the window ?
TST.W wd_ReqCount(A0)
BNE.B KeepEvent * Yes
* ------------ Does the window have menues ?
TST.L wd_MenuStrip(A0)
BEQ.B KeepEvent * No
* ------------ Is the RMBTRAP flag set ?
MOVEQ.L #1,D0
AND.W wd_Flags(A0),D0
BNE.B KeepEvent * Yes
* ------------ Down = TRUE
MOVEQ.L #TRUE,D2
* ------------ Tell task to popup the menues.
MOVE.L sd_MenuDownSig(A2),D0
BRA.B SigAndRemove
* ------------ Check out if the user has selected something.
* ------------ Is menubutton released ?
MouseIsDown: CMPI.W #MENUUP,D1
BNE.B 1$ * No
* ------------ Down = FALSE
MOVEQ.L #FALSE,D2
* ------------ Tell our task.
MOVE.L sd_MenuUpSig(A2),D0
BRA.B SigAndRemove
* ------------ Multiple select ?
1$: CMPI.W #SELECTDOWN,D1
BNE.B CheckSelUp * No
MOVE.L sd_SelectDownSig(A2),D0
SigAndRemove: MOVEA.L (A2),A1 * sd_PopUpMenuTask(A2)
JSR _LVOSignal(A6)
BRA.B RemoveEvent
* ------------ SELECTUP isn't used but remove the event anyway
* ------------ Intuition may be confused since no SELECTDOWN is sent.
CheckSelUp: CMPI.W #SELECTUP,D1
BNE.B KeepEvent * No
* ------------ Remove the event from the list.
RemoveEvent: MOVE.L A5,D0 * First event in list ?
BNE.B 1$ * No
MOVEA.L (A4),A3 * ie_NextEvent(A4)
BRA.B NextEvent
1$: MOVE.L (A4),(A5) * ie_NextEvent(A4),ie_NextEvent(A5)
BRA.B NextEvent
* ------------ Keep this message.
KeepEvent: MOVE.L A4,A5
* ------------ Check out the next event.
NextEvent: MOVE.L (A4),A4 * ie_NextEvent(A4)
BRA.W MoreEvents
Done MOVE.W D2,sd_Down(A2)
MOVE.L A3,D0
MOVEM.L (A7)+,D2/A2-A6
RTS
END