I have just attempted to intercept the #selectionChanging event from a
TreeView. I have copied and adapted the code from the Class Hierarchy Browser to put up a yes/no dialog if the associated'data' view has unsaved modifications. The net result is an infinite loop of dialog appearances, whatever the answer given to the dialog (The 'value' of the selection changing event is being set to the answer from the dialog). If I comment out just the code to put up the dialog then no looping occurs. The Dolphin 5.0 release notes includes a reference to this problem, refering to the tree control as being buggy in this respect. It is not completely clear whether the release note is highlighting the problem or implying that it has been fixed. As a novice when it comes to Win32 GUI programming, I am hoping I have just missed out something 'obvious'. Suggestions as to what this might be would be appreciated. Neil Dyer Email: [hidden email] --- Outgoing mail is certified Virus Free using AVG 6.0. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.474 / Virus Database: 272 - Release Date: 18/04/2003 |
Neil,
> I have just attempted to intercept the #selectionChanging event from a > TreeView. [] It seems to work as expected in 5.1?. I created a Shell subclass containing a TreeView, populated the tree, hooked onto the #selectionChanging: event and added the following method to my subclass... onSelectionChanging: aValueHolder aValueHolder value: (MessageBox confirm: 'Allow change') Apart from the MessageBox being displayed once before the Shell was visible (which should be easily fixable) the tree selection was only changed if I selected "Yes" - and I didn't get a recursive loop either. Can you post a bit of code to show what you are doing? -- Ian |
Thanks for the feedback Ian. I've created a similar minimal Shell subclass
in 5.1 which can be made to loop when choosing 'No' repeatedly, but performs as you described when 'Yes' is chosen. The looping occurs on selecting an entry in the tree when there is no current selection in the tree (In what I was doing, this was the only case where intercepting the change was relevant). Can you reproduce this behaviour? Below is the method called on #selectionChanged: that can go into an infinite loop when the tree has no current selection (adapted from SmalltalkWorkspace>>prompt:toSaveChanges: ). onPromptToSaveChanges: aSelectionChangingEvent aSelectionChangingEvent canIntercept ifFalse: ^ aSelectionChangingEvent value ]. self isModified ifTrue: | response | self ensureVisible. response := ( MessageBox new ) taskModal; owner: self view; confirm: ( 'There are unsaved %1 changes.%n%nDo you wish to retain them?' formatWith: self descriptorClass name ). response ifTrue: self ensureVisible. aSelectionChangingEvent value: response not. ]. ]. ^ aSelectionChangingEvent value Commenting out the send of #taskModal changes the behaviour so that the dialog only appears one, two or three times when choosing not to retain changes. The dialog appears two or three times when changing to no selection (from no selection). Neil "Ian Bartholomew" <[hidden email]> wrote in message news:DxZoa.10023$[hidden email]... > Neil, > > > I have just attempted to intercept the #selectionChanging event from a > > TreeView. > [] > > It seems to work as expected in 5.1?. I created a Shell subclass > containing a TreeView, populated the tree, hooked onto the > #selectionChanging: event and added the following method to my > subclass... > > onSelectionChanging: aValueHolder > aValueHolder value: (MessageBox confirm: 'Allow change') > > Apart from the MessageBox being displayed once before the Shell was > visible (which should be easily fixable) the tree selection was only > changed if I selected "Yes" - and I didn't get a recursive loop either. --- Outgoing mail is certified Virus Free using AVG 6.0. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.474 / Virus Database: 272 - Release Date: 18/04/2003 |
Neil,
> I've created a similar minimal Shell > subclass in 5.1 which can be made to loop when choosing 'No' > repeatedly, but performs as you described when 'Yes' is chosen. It might be best if you mail me a copy of this minimal shell so I can see exactly what it is that you are trying to do. It does look as if you have just copied too much from the original method though - a lot of your posted code is probably not needed. Assuming your tree contains Objects (as opposed to Strings) then I would have thought you could just get away with onTreeSelectionChanging: aValueHolder (treePresenter hasSelection and: [treePresenter selection isModified]) ifFalse: [^self]. aValueHolder value: (MessageBox confirm: 'Selection has been modified. Continue?') -- Ian |
Free forum by Nabble | Edit this page |