# HG changeset patch # User Claus Gittinger # Date 1029773465 -7200 # Node ID 0595db55a829282f1107932dbb8923649c928495 # Parent 1b87b322f2685b94325b9fd44a98f79c85782cd4 preps for delayedMenu diff -r 1b87b322f268 -r 0595db55a829 MenuItem.st --- a/MenuItem.st Mon Aug 19 18:09:30 2002 +0200 +++ b/MenuItem.st Mon Aug 19 18:11:05 2002 +0200 @@ -16,7 +16,7 @@ Object subclass:#MenuItem instanceVariableNames:'activeHelpKey enabled label value nameKey adornment translateLabel isButton startGroup isVisible hideMenuOnActivated - triggerOnDown' + triggerOnDown delayMenu' classVariableNames:'' poolDictionaries:'' category:'Views-Support' @@ -181,38 +181,6 @@ "Modified: / 4.2.2000 / 12:38:44 / cg" ! -font - "get the specific font for an item or nil - " - adornment notNil ifTrue:[ - ^ adornment font - ]. - ^ nil -! - -font:aFont - "set the index of the access character in the label text or string, or nil if none - " - - (aFont isNil and:[adornment isNil]) ifFalse:[ - self adornment font:aFont - ] -! - -hideMenuOnActivated - "hide the menu when the item was activated; the default is true - " - ^ hideMenuOnActivated ? true - -! - -hideMenuOnActivated:aBool - "hide the menu when the item was activated; the default is true - " - hideMenuOnActivated := aBool ? true - -! - isVisible ^ isVisible ? true ! @@ -243,36 +211,6 @@ ]. ! -label - ^ self filteredLabel "/ label - - "Created: / 25.2.1997 / 19:48:16 / cg" - "Modified: / 19.6.1998 / 00:02:55 / cg" -! - -label:aString - label := aString - - "Created: 25.2.1997 / 19:55:16 / cg" -! - -labelImage - "gets the labelImage - " - adornment notNil ifTrue:[ - ^ adornment labelImage value - ]. - ^ nil -! - -labelImage:aResourceRetriever - "set the labelImage - " - aResourceRetriever notNil ifTrue:[ - self adornment labelImage:aResourceRetriever - ] -! - nameKey ^ nameKey @@ -316,44 +254,6 @@ "Modified: / 4.2.2000 / 12:39:30 / cg" ! -showBusyCursorWhilePerforming - "get the flag which controls if a busy cursor is to be shown - while performing the menu action. Defaults to false." - - adornment notNil ifTrue:[ - ^ adornment showBusyCursorWhilePerforming - ]. - ^ nil -! - -showBusyCursorWhilePerforming:aBoolean - "set/clear the flag which controls if a busy cursor is to be shown - while performing the menu action. Defaults to false." - - ((aBoolean == true) or:[adornment notNil]) ifTrue:[ - self adornment showBusyCursorWhilePerforming:aBoolean - ] -! - -startGroup - "start group #left #right #center ... or nil - at the moment only #right is implemented - " - ^ startGroup ? #left -! - -startGroup:aSymbol - "start group #left #right #center ... - at the moment only #right is implemented - " - (#(nil #left #right) includes:startGroup) ifTrue:[ - startGroup := aSymbol - ] ifFalse:[ - self warn:('unsupported group: ', aSymbol printString ). - startGroup := #left - ] -! - submenu adornment notNil ifTrue:[ ^ adornment submenu @@ -387,19 +287,6 @@ "Modified: / 4.2.2000 / 12:40:19 / cg" ! -triggerOnDown - "trigger the action if pressed - " - ^ triggerOnDown ? false - -! - -triggerOnDown:aBool - "trigger the action if pressed - " - triggerOnDown := aBool. -! - value ^ value @@ -470,6 +357,20 @@ "Created: / 14.8.1998 / 15:39:12 / cg" ! +delayMenu + "return true, the menu is shown delayed, if the button is still pressed after a while. + Only useful with buttons in non-popup-menus + " + ^ delayMenu ? false +! + +delayMenu:aBoolean + "if true, the menu is shown delayed, if the button is still pressed after a while. + Only useful with buttons in non-popup-menus + " + delayMenu := aBoolean +! + disable enabled := false @@ -494,23 +395,18 @@ enabled := something ! -horizontalLayout - "on default submenus has a vertical layout; - true, the submenu has a horizontal layout. +hideMenuOnActivated + "hide the menu when the item was activated; the default is true " - adornment notNil ifTrue:[ - ^ adornment horizontalLayout - ]. - ^ nil + ^ hideMenuOnActivated ? true + ! -horizontalLayout:aBoolean - "on default submenus has a vertical layout; - true, the submenu has a horizontal layout. - " - ((aBoolean == true) or:[adornment notNil]) ifTrue:[ - self adornment horizontalLayout:aBoolean - ]. +hideMenuOnActivated:aBool + "hide the menu when the item was activated; the default is true + " + hideMenuOnActivated := aBool ? true + ! indication @@ -534,6 +430,93 @@ "Modified: / 14.8.1998 / 15:11:25 / cg" ! +showBusyCursorWhilePerforming + "get the flag which controls if a busy cursor is to be shown + while performing the menu action. Defaults to false." + + adornment notNil ifTrue:[ + ^ adornment showBusyCursorWhilePerforming + ]. + ^ nil +! + +showBusyCursorWhilePerforming:aBoolean + "set/clear the flag which controls if a busy cursor is to be shown + while performing the menu action. Defaults to false." + + ((aBoolean == true) or:[adornment notNil]) ifTrue:[ + self adornment showBusyCursorWhilePerforming:aBoolean + ] +! + +translateLabel + "returns whether label is translated + " + ^translateLabel ? false + + +! + +translateLabel:anBoolean + "sets whether label is translated + " + translateLabel := anBoolean + + +! + +triggerOnDown + "trigger the action if pressed + " + ^ triggerOnDown ? false + +! + +triggerOnDown:aBool + "trigger the action if pressed + " + triggerOnDown := aBool. +! ! + +!MenuItem methodsFor:'accessing-look'! + +font + "get the specific font for an item or nil + " + adornment notNil ifTrue:[ + ^ adornment font + ]. + ^ nil +! + +font:aFont + "set the index of the access character in the label text or string, or nil if none + " + + (aFont isNil and:[adornment isNil]) ifFalse:[ + self adornment font:aFont + ] +! + +horizontalLayout + "on default submenus has a vertical layout; + true, the submenu has a horizontal layout. + " + adornment notNil ifTrue:[ + ^ adornment horizontalLayout + ]. + ^ nil +! + +horizontalLayout:aBoolean + "on default submenus has a vertical layout; + true, the submenu has a horizontal layout. + " + ((aBoolean == true) or:[adornment notNil]) ifTrue:[ + self adornment horizontalLayout:aBoolean + ]. +! + isButton "returns whether item looks like a Button " @@ -550,20 +533,53 @@ ! -translateLabel - "returns whether label is translated +label + ^ self filteredLabel "/ label + + "Created: / 25.2.1997 / 19:48:16 / cg" + "Modified: / 19.6.1998 / 00:02:55 / cg" +! + +label:aString + label := aString + + "Created: 25.2.1997 / 19:55:16 / cg" +! + +labelImage + "gets the labelImage " - ^translateLabel ? false - - + adornment notNil ifTrue:[ + ^ adornment labelImage value + ]. + ^ nil ! -translateLabel:anBoolean - "sets whether label is translated +labelImage:aResourceRetriever + "set the labelImage + " + aResourceRetriever notNil ifTrue:[ + self adornment labelImage:aResourceRetriever + ] +! + +startGroup + "start group #left #right #center ... or nil + at the moment only #right is implemented " - translateLabel := anBoolean + ^ startGroup ? #left +! - +startGroup:aSymbol + "start group #left #right #center ... + at the moment only #right is implemented + " + (#(nil #left #right) includes:startGroup) ifTrue:[ + startGroup := aSymbol + ] ifFalse:[ + self warn:('unsupported group: ', aSymbol printString ). + startGroup := #left + ] ! ! !MenuItem methodsFor:'accessing-resource'! @@ -1113,5 +1129,5 @@ !MenuItem class methodsFor:'documentation'! version - ^ '$Header: /cvs/stx/stx/libview2/MenuItem.st,v 1.47 2002-05-14 09:20:51 cg Exp $' + ^ '$Header: /cvs/stx/stx/libview2/MenuItem.st,v 1.48 2002-08-19 16:11:05 cg Exp $' ! !