PopUpMenu.st
changeset 1354 c260c896ea66
parent 1285 8dcd07116b60
child 1403 ddc59498d1c3
equal deleted inserted replaced
1353:5dac6aa6ac96 1354:c260c896ea66
     7  inclusion of the above copyright notice.   This software may not
     7  inclusion of the above copyright notice.   This software may not
     8  be provided or otherwise made available to, or used by, any
     8  be provided or otherwise made available to, or used by, any
     9  other person.  No title to or ownership of the software is
     9  other person.  No title to or ownership of the software is
    10  hereby transferred.
    10  hereby transferred.
    11 "
    11 "
       
    12 
       
    13 'From Smalltalk/X, Version:3.2.1 on 20-oct-1997 at 3:09:17 pm'                  !
    12 
    14 
    13 PopUpView subclass:#PopUpMenu
    15 PopUpView subclass:#PopUpMenu
    14 	instanceVariableNames:'menuView lastSelection memorize hideOnLeave actionLabels
    16 	instanceVariableNames:'menuView lastSelection memorize hideOnLeave actionLabels
    15 		actionLines actionValues hideOnRelease defaultHideOnRelease'
    17 		actionLines actionValues hideOnRelease defaultHideOnRelease'
    16 	classVariableNames:'DefaultHideOnRelease'
    18 	classVariableNames:'DefaultHideOnRelease'
   666 !PopUpMenu class methodsFor:'defaults'!
   668 !PopUpMenu class methodsFor:'defaults'!
   667 
   669 
   668 updateStyleCache
   670 updateStyleCache
   669     "extract values from the styleSheet and cache them in class variables"
   671     "extract values from the styleSheet and cache them in class variables"
   670 
   672 
   671     <resource: #style (#popupHideOnRelease)>
   673     <resource: #style (#'popup.hideOnRelease')>
   672 
   674 
   673     DefaultHideOnRelease := StyleSheet at:#popupHideOnRelease default:true.
   675     DefaultHideOnRelease := StyleSheet at:'popup.hideOnRelease' default:true.
   674 
   676 
   675     "Modified: 17.1.1997 / 23:19:29 / cg"
   677     "Modified: 20.10.1997 / 15:08:44 / cg"
   676 ! !
   678 ! !
   677 
   679 
   678 !PopUpMenu methodsFor:'ST-80 activation'!
   680 !PopUpMenu methodsFor:'ST-80 activation'!
   679 
   681 
   680 startUp
   682 startUp
   700      or - if no values where specified - return the index.
   702      or - if no values where specified - return the index.
   701      If nothing was selected, return 0.
   703      If nothing was selected, return 0.
   702      Modal - i.e. stay in the menu until finished.
   704      Modal - i.e. stay in the menu until finished.
   703      This is the ST-80 way of launching a menu."
   705      This is the ST-80 way of launching a menu."
   704 
   706 
   705     |return rec sel0 sel1 arg|
   707     |return rec sel0 sel1 arg myAction|
   706 
   708 
   707     return := 0.
   709     return := 0.
   708 "/    menuView args notNil ifTrue:[
   710 "/    menuView args notNil ifTrue:[
   709 "/        return := nil
   711 "/        return := nil
   710 "/    ].
   712 "/    ].
   717     "/ supported when ST/X menus were originally written.
   719     "/ supported when ST/X menus were originally written.
   718     "/ The old ST/X mechanism may vanish.
   720     "/ The old ST/X mechanism may vanish.
   719     "/
   721     "/
   720 
   722 
   721     menuView action isNil ifTrue:[
   723     menuView action isNil ifTrue:[
       
   724         myAction := true.
   722         menuView action:[:menuView :selected |
   725         menuView action:[:menuView :selected |
   723             |actionIndex value sel retVal selIdx
   726             |actionIndex value sel retVal selIdx
   724              args selectors checkFlags check|
   727              args selectors checkFlags check|
   725 
   728 
   726             selected isNil ifTrue:[
   729             selected isNil ifTrue:[
   784     aPoint isNil ifTrue:[
   787     aPoint isNil ifTrue:[
   785         self showAtPointer
   788         self showAtPointer
   786     ] ifFalse:[
   789     ] ifFalse:[
   787         self showAt:aPoint.
   790         self showAt:aPoint.
   788     ].
   791     ].
       
   792     myAction == true ifTrue:[menuView action:nil].
   789 
   793 
   790     "/ 
   794     "/ 
   791     "/ mhmh an ST/X menu started the ST-80 way
   795     "/ mhmh an ST/X menu started the ST-80 way
   792     "/
   796     "/
   793     (sel0 notNil or:[sel1 notNil]) ifTrue:[
   797     (sel0 notNil or:[sel1 notNil]) ifTrue:[
   804      Transcript showCR:(PopUpMenu labels:#('foo' 'bar' 'baz')
   808      Transcript showCR:(PopUpMenu labels:#('foo' 'bar' 'baz')
   805                                   values:#(foo bar baz)) startUp
   809                                   values:#(foo bar baz)) startUp
   806     "
   810     "
   807 
   811 
   808     "Created: 10.1.1996 / 20:11:42 / cg"
   812     "Created: 10.1.1996 / 20:11:42 / cg"
   809     "Modified: 2.4.1997 / 16:03:23 / cg"
   813     "Modified: 17.10.1997 / 02:34:52 / cg"
   810 !
   814 !
   811 
   815 
   812 startUpWithHeading:aString
   816 startUpWithHeading:aString
   813     "start the menu modal - return the selected value,
   817     "start the menu modal - return the selected value,
   814      or - if no values where specified - return the index.
   818      or - if no values where specified - return the index.
  1322 ! !
  1326 ! !
  1323 
  1327 
  1324 !PopUpMenu class methodsFor:'documentation'!
  1328 !PopUpMenu class methodsFor:'documentation'!
  1325 
  1329 
  1326 version
  1330 version
  1327     ^ '$Header: /cvs/stx/stx/libwidg/PopUpMenu.st,v 1.66 1997-07-28 10:25:22 cg Exp $'
  1331     ^ '$Header: /cvs/stx/stx/libwidg/PopUpMenu.st,v 1.67 1997-10-21 18:12:31 cg Exp $'
  1328 ! !
  1332 ! !