[squeak-dev] find in pane of TabbedPalette (BookMorph)

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[squeak-dev] find in pane of TabbedPalette (BookMorph)

Ralph Boland
The GUI for SmaCC  is a TabbedPalette  in which 3 of its four pages are editable
(the scanner definition page, the grammar page, and the test page).
I want to be able to use editing features on these 3 pages such as
find/replace.
But find doesn't work because when invoked (when find is invoked) and the method
                  TextMorphEditor>>againOrSame: boolean
is invoked (see method code below) the line:
                 (bk := morph ownerThatIsA: BookMorph) ifNotNil:
sets bk to a TabbedPalette object.  (If bk is set to  nil the the find
operation is invoked and works).
This results in the line:
                  [bk findText: keys.
being invoked.  The first line of findText:   is:
                 allText := self valueOfProperty: #allText ifAbsent: [#()].
This sets  allText to  #()  which turn prevents any search from being
carried out.  :-(
       

TextMorphEditor>>againOrSame: bool
        | bk keys |
        (bk := morph ownerThatIsA: BookMorph) ifNotNil:
                        [(keys := bk valueOfProperty: #tempSearchKey ifAbsent: [nil]) ifNil:
                                        ["Cmd-f"

                                        keys := bk valueOfProperty: #searchKey ifAbsent: [nil] "Cmd-g"]
                                ifNotNil: [bk removeProperty: #tempSearchKey].
                        keys ifNotNil:
                                        [keys notEmpty
                                                ifTrue:
                                                        [bk findText: keys.
                                                        ^(morph respondsTo: #editView)
                                                                ifTrue: [morph editView selectionInterval: self selectionInterval]]]].
        super againOrSame: bool.
        (morph respondsTo: #editView)
                ifTrue: [morph editView selectionInterval: self selectionInterval]



Now my question is:
    What is the best way to modify code so that find does what I want
it to do (apply find to the text in the
text morph containing the cursor)?
My best solution so far is to subclass  TextMorphEditor  and use it so
that a version of  againOrSame: is invoked
that does not set  bk (and avoids the use of super).
I could instead subclass TabbedPalette and use it to deny that it is a
kind of  BookMorph but that
is very ugly.

I don't understand in any case why  findText: is being invoked for
TabbedPalette  in the first place.
Isn't what I am trying to do what most developers expect to happen?
That is:  Why does the code as it exists make sense?

Regards,

Ralph Boland



--
Quantum Theory cannot save us from the
tyranny of a deterministic universe.
But it does give God something to do.