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 >
Text File  |  1990-12-31  |  4KB  |  145 lines

  1.            opt      l+,c+,d+,y+
  2.            opt      ow1+,ow2+,ow3+,ow4+,ow5+,ow6+
  3.  
  4.                INCLUDE    "exec/types.i"
  5.            INCLUDE      "PopUpMenu.i"
  6.  
  7. QUALIFIERS     EQU  IEQUALIFIER_LSHIFT+IEQUALIFIER_RSHIFT+IEQUALIFIER_CONTROL+IEQUALIFIER_LALT+IEQUALIFIER_RALT+IEQUALIFIER_LCOMMAND+IEQUALIFIER_RCOMMAND+IEQUALIFIER_MIDBUTTON+IEQUALIFIER_LEFTBUTTON
  8. FALSE           EQU     0
  9. TRUE           EQU     1
  10.  
  11.            xdef     @PopUpHandler
  12.  
  13.            xref     _IntuitionBase
  14.  
  15.            section     text,code
  16.  
  17. @PopUpHandler: MOVEM.L     D2/A2-A6,-(A7)
  18.            MOVEA.L     A0,A3          *A3 = Events
  19.            MOVEA.L     A1,A2          *A2 = MySignals
  20.            MOVEA.L     A3,A4          *A4 = Event
  21.            SUB.L     A5,A5          *A5 = LastEvent
  22.            MOVEA.L     (AbsExecBase).W,A6
  23.  
  24.            MOVE.W     sd_Down(A2),D2
  25.            BEQ.B     NoMoveSignal
  26.  
  27. * ------------ Tell the task we are living.
  28.            MOVEA.L     (A2),A1          *sd_PopUpMenuTask
  29.            MOVE.L     sd_MouseMovedSig(A2),D0
  30.            JSR     _LVOSignal(A6)
  31.  
  32. * ------------ No more events ?
  33. NoMoveSignal:
  34. MoreEvents:    MOVE.L     A4,D0
  35.            BEQ.W     Done
  36.  
  37. * ------------ Mouseevent ?
  38.            MOVEQ.L     #IECLASS_RAWMOUSE,D0
  39.            CMP.B     ie_Class(A4),D0
  40.            BNE.W     KeepEvent      * Don't care about this message.
  41.  
  42.            MOVE.W     ie_Code(A4),D1
  43.  
  44. * ------------ Is menubutton already pressed.
  45.            TST.W     D2
  46.            BNE.B     MouseIsDown      * Yes
  47.  
  48. * ------------ Menubutton pressed ?
  49.            MOVEQ.L     #MENUDOWN,D0
  50.            CMP.W     D1,D0
  51.            BNE.B     KeepEvent      * No
  52.  
  53. * ------------ Is any qualifierkey also pressed ?
  54.            MOVE.W     #QUALIFIERS,D0
  55.            AND.W     ie_Qualifier(A4),D0
  56.            BNE.B     KeepEvent      * Yes
  57.  
  58. * ------------ Is any screen active ?
  59.            MOVEA.L     _IntuitionBase,A1
  60.            MOVEA.L     ib_ActiveScreen(A1),A0
  61.            MOVE.L     A0,D0
  62.            BEQ.B     KeepEvent      * No
  63.  
  64. * ------------ Is the mouse in the titlebar ?
  65.            MOVE.B     sc_BarHeight(A0),D0
  66.            EXT.W     D0
  67.            CMP.W     sc_MouseY(A0),D0
  68.            BGT.B     KeepEvent      * Yes
  69.  
  70. * ------------ Is any window active ?
  71.            MOVEA.L     ib_ActiveWindow(A1),A0
  72.            MOVE.L     A0,D0
  73.            BEQ.B     KeepEvent      * No
  74.  
  75. * ------------ Is any requester blocking the window ?
  76.            TST.W     wd_ReqCount(A0)
  77.            BNE.B     KeepEvent      * Yes
  78.  
  79. * ------------ Does the window have menues ?
  80.            TST.L     wd_MenuStrip(A0)
  81.            BEQ.B     KeepEvent      * No
  82.  
  83. * ------------ Is the RMBTRAP flag set ?
  84.            MOVEQ.L     #1,D0
  85.            AND.W     wd_Flags(A0),D0
  86.            BNE.B     KeepEvent      * Yes
  87.  
  88. * ------------ Down = TRUE
  89.            MOVEQ.L     #TRUE,D2
  90.  
  91. * ------------ Tell task to popup the menues.
  92.            MOVE.L     sd_MenuDownSig(A2),D0
  93.            BRA.B     SigAndRemove
  94.  
  95. * ------------ Check out if the user has selected something.
  96. * ------------ Is menubutton released ?
  97. MouseIsDown:   CMPI.W     #MENUUP,D1
  98.            BNE.B     1$          * No
  99.  
  100. * ------------ Down = FALSE
  101.            MOVEQ.L     #FALSE,D2
  102.  
  103. * ------------ Tell our task.
  104.            MOVE.L     sd_MenuUpSig(A2),D0
  105.            BRA.B     SigAndRemove
  106.  
  107. * ------------ Multiple select ?
  108. 1$:           CMPI.W     #SELECTDOWN,D1
  109.            BNE.B     CheckSelUp      * No
  110.  
  111.            MOVE.L     sd_SelectDownSig(A2),D0
  112.  
  113. SigAndRemove:  MOVEA.L     (A2),A1          * sd_PopUpMenuTask(A2)
  114.            JSR     _LVOSignal(A6)
  115.            BRA.B     RemoveEvent
  116.  
  117. * ------------ SELECTUP isn't used but remove the event anyway
  118. * ------------ Intuition may be confused since no SELECTDOWN is sent.
  119. CheckSelUp:    CMPI.W     #SELECTUP,D1
  120.            BNE.B     KeepEvent      * No
  121.  
  122. * ------------ Remove the event from the list.
  123. RemoveEvent:   MOVE.L     A5,D0          * First event in list ?
  124.            BNE.B     1$          * No
  125.            MOVEA.L     (A4),A3          * ie_NextEvent(A4)
  126.            BRA.B     NextEvent
  127. 1$:           MOVE.L     (A4),(A5)        * ie_NextEvent(A4),ie_NextEvent(A5)
  128.            BRA.B     NextEvent
  129.  
  130. * ------------ Keep this message.
  131. KeepEvent:     MOVE.L     A4,A5
  132.  
  133. * ------------ Check out the next event.
  134. NextEvent:     MOVE.L     (A4),A4          * ie_NextEvent(A4)
  135.            BRA.W     MoreEvents
  136.  
  137. Done           MOVE.W     D2,sd_Down(A2)
  138.            MOVE.L     A3,D0
  139.  
  140.            MOVEM.L     (A7)+,D2/A2-A6
  141.            RTS
  142.  
  143.            END
  144.  
  145.