# HG changeset patch # User Claus Gittinger # Date 921955330 -3600 # Node ID 0460739b9e9728fbb5dc5cdaf4869774eb86df26 # Parent c3eb38fa149d7140c4caaa9bc14f286c8b262bb1 checkin from browser diff -r c3eb38fa149d -r 0460739b9e97 ExtendedComboBox.st --- a/ExtendedComboBox.st Sat Mar 20 15:26:46 1999 +0100 +++ b/ExtendedComboBox.st Sat Mar 20 19:42:10 1999 +0100 @@ -8,8 +8,8 @@ category:'Views-Interactors' ! -SimpleView subclass:#MenuWrapper - instanceVariableNames:'shadowView comboBox widget pointerScrollbarView' +PopUpView subclass:#MenuWrapper + instanceVariableNames:'comboBox widget pointerScrollbarView' classVariableNames:'' poolDictionaries:'' privateIn:ExtendedComboBox @@ -666,8 +666,8 @@ ] ifTrue:[ menuWrapper unmap ]. - menuWrapper windowGroup:nil. - self windowGroup removeView:menuWrapper. +"/ menuWrapper windowGroup:nil. +"/ self windowGroup removeView:menuWrapper. ]. menuButton turnOff. @@ -676,21 +676,15 @@ openMenu "pull the menu - triggered from the button " - |winGroup h w menuOrigin menuPrfExt useableExt| + |h w menuOrigin menuPrfExt useableExt| menuWrapper isNil ifTrue:[ menuWidget isNil ifTrue:[^ self]. menuWrapper := MenuWrapper new. menuWrapper for:menuWidget in:self. - ]. menuButton turnOn. - (winGroup := self windowGroup) notNil ifTrue:[ - menuWrapper windowGroup:winGroup. - winGroup addTopView:menuWrapper. - ]. - menuOrigin := device translatePoint:(0@height) from:(self id) to:(device rootWindowId). useableExt := device usableExtent. menuPrfExt := menuWrapper preferredExtent. @@ -712,13 +706,7 @@ ] ]. menuWrapper origin:menuOrigin extent:(w @ h). - - menuWrapper realized ifFalse:[ - menuWrapper realize. - ] ifTrue:[ - device mapWindow:menuWrapper id. - ]. - menuWrapper makeFullyVisible. + menuWrapper openModal. ! ! !ExtendedComboBox::MenuWrapper methodsFor:'accessing'! @@ -846,90 +834,17 @@ (key == #Tab or:[key == #ISO_Left_Tab]) ifTrue:[ comboBox closeMenu ] ifFalse:[ - view := (self detectViewAtX:x y:y) ? widget. - view keyPress:key x:x y:y. + x notNil ifTrue:[ + view := (self detectViewAtX:x y:y) ? widget. + view keyPress:key x:x y:y. + ] ifFalse:[ + super keyPress:key x:x y:y. + ] ] ! ! -!ExtendedComboBox::MenuWrapper methodsFor:'grabbing'! - -grabMouseAndKeyboard - "get exclusive access to pointer and keyboard. - " - |sensor| - - realized ifTrue:[ - sensor := self sensor. - - device activePointerGrab ~~ self ifTrue:[ - sensor notNil ifTrue:[ - sensor flushMotionEventsFor:nil. - ]. - - (device grabPointerInView:self) ifFalse:[ - Delay waitForSeconds:0.1. - (device grabPointerInView:self) ifFalse:[ - "give up" - self unmap - ] - ] - ]. - - device activeKeyboardGrab ~~ self ifTrue:[ - sensor notNil ifTrue:[ - device sync. - sensor flushKeyboardFor:nil - ]. - device grabKeyboardInView:self. - self getKeyboardFocus. - ] - ] -! - -ungrabMouseAndKeyboard - "ungrab resources (mouse and keyboard) - " - |sensor| - - device ungrabPointer. - - (sensor := self sensor) notNil ifTrue:[ - "/ make certain all X events have been received - device sync. - "/ now all events have been received. - "/ now, flush all pointer events - sensor flushKeyboardFor:nil - ]. - device ungrabKeyboard. - -! ! - !ExtendedComboBox::MenuWrapper methodsFor:'initialization'! -create - "create the shadow view for a none contained submenu - " - super create. - (PopUpView styleSheet at:'popup.shadow' default:false) ifTrue:[ - shadowView isNil ifTrue:[ - shadowView := (ShadowView onDevice:device) for:self - ] ifFalse:[ - self saveUnder:true. - ]. - ] - - -! - -destroy - "ungrab resources (mouse and keyboard) - " - self ungrabMouseAndKeyboard. - super destroy. - shadowView notNil ifTrue:[shadowView destroy]. - -! - for:aWidget in:aReceiver "create a wrapper for a widget and the receiver, an extented comboBox " @@ -939,6 +854,8 @@ widget := aWidget. hasScr := aWidget isScrollWrapper. + self borderWidth:0. + comboBox menuIsScrollable ifTrue:[ hasScr ifFalse:[ widget := ScrollableView forView:aWidget. @@ -958,11 +875,11 @@ ] ! -initialize - "setup default; set width of border to 0 - " - super initialize. - self borderWidth:0. +hideRequest + "hide request from windowGroup (i.e. via Escape key). + Can be redefined in subclasses which dont like this" + + comboBox closeMenu ! @@ -971,42 +888,11 @@ " pointerScrollbarView := nil. super mapped. - self grabMouseAndKeyboard. -! -realize - "realize menu view and shadowView. - Because of #saveUnder of ShadowView the order of realize is significant: - shadowView must be realized before self - " - self hiddenOnRealize:true. - super realize. - self resize. - - shadowView notNil ifTrue:[ - shadowView realize. - ]. - super map. - self raise. - -! - -unmap - "ungrab resources (mouse and keyboard) - " - self ungrabMouseAndKeyboard. - super unmap. - shadowView notNil ifTrue:[shadowView unmap]. ! ! !ExtendedComboBox::MenuWrapper methodsFor:'queries'! -isPopUpView - "return true, since I want to come up without decoration - " - ^ true -! - raiseDeiconified ^ self raise @@ -1057,5 +943,5 @@ !ExtendedComboBox class methodsFor:'documentation'! version - ^ '$Header: /cvs/stx/stx/libwidg2/ExtendedComboBox.st,v 1.4 1999-03-20 14:26:46 cg Exp $' + ^ '$Header: /cvs/stx/stx/libwidg2/ExtendedComboBox.st,v 1.5 1999-03-20 18:42:10 cg Exp $' ! !