home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 372.lha / PopUpMenu_3.2 / Source / InputHandler.a < prev    next >
Text File  |  1990-05-06  |  4KB  |  141 lines

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