<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Hi Marcel,</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
thanks for your reply. Do you really think checking the stack would not violate any law of modularity, intuitive interfaces and low coupling?</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
But what is the problem with #hasUnacceptedEdits:? Why would you change this in PluggableTextMorph? I added an instvar <span>hasUnacceptedEditsSinceKeystroke to the TextMorphForEditView, set it to true in #hasUnacceptedEdits: if aBoolean is true and set it
 to false in #keyStroke: immediately before calling super keyStroke. At first glance, I could not find any wrong behavior.<br>
</span><span></span></div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span><br>
</span></div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span><span><b>keyStroke: evt</b><br>
</span></span></div>
<blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;">
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span>
<div>| view |</div>
</span></div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span>
<div><br>
</div>
</span></div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span>
<div>editView deleteBalloon.</div>
</span></div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span>
<div>self editor model: editView model.  "For evaluateSelection"</div>
</span></div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span>
<div>view := editView.  "Copy into temp for case of a self-mutating doit"</div>
</span></div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span>
<div>(acceptOnCR and: [evt keyCharacter = Character cr])</div>
</span></div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span>
<div> ifTrue: [^ self editor accept].</div>
</span></div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span>
<div>hasUnacceptedEditsSinceKeystroke := false.</div>
</span></div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span>
<div>super keyStroke: evt.</div>
</span></div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span>
<div>view scrollSelectionIntoView.</div>
</span></div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span>
<div><br>
</div>
</span></div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span>
<div>(self readOnly not and: hasUnacceptedEditsSinceKeystroke)</div>
</span></div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span><span> ifTrue: [view textEdited: self contents]</span></span></div>
</blockquote>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span><span><br>
</span></span></div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span><span><span><b>hasUnacceptedEdits: aBoolean</b><br>
</span></span></span></div>
<blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;">
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span><span>
<div>"Set the hasUnacceptedEdits flag in my view."</div>
</span></span></div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span><span>
<div><br>
</div>
</span></span></div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span><span>
<div>aBoolean ifTrue: [hasUnacceptedEditsSinceKeystroke := true].</div>
</span></span></div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span><span><span>editView hasUnacceptedEdits: aBoolean</span></span></span></div>
</blockquote>
<font color="#000000" face="Calibri, Helvetica, sans-serif">
<div><font color="#000000" face="Calibri, Helvetica, sans-serif"><br>
</font></div>
Best,</font>
<div><font color="#000000" face="Calibri, Helvetica, sans-serif">Christoph<br>
</font>
<div id="appendonsend"></div>
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<br>
</div>
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>Von:</b> Squeak-dev <squeak-dev-bounces@lists.squeakfoundation.org> im Auftrag von Marcel Taeumel <marcel.taeumel@hpi.de><br>
<b>Gesendet:</b> Freitag, 19. Juli 2019 08:08 Uhr<br>
<b>An:</b> JOHN SARKELA via Squeak-dev <squeak-dev@lists.squeakfoundation.org><br>
<b>Betreff:</b> Re: [squeak-dev] TextMorphForEditView calls #textEdited: after every cmd action</font>
<div> </div>
</div>
<div>
<div id="x___MailbirdStyleContent" style="font-size:10pt; font-family:Arial; color:#000000">
Hi Christoph,
<div><br>
</div>
<div>yes, the current implementation of #textEdited: is not perfect. It is difficult to seperate any change from user-made edits. We cannot even know whether those incoming user-input events are not generated by a script. :-)</div>
<div><br>
</div>
<div>If you want to get an overview of higher-level user edits, take a look at the following methods:</div>
<div><br>
</div>
<div>TextEditor (or SmalltalkEditor) class >> #initializeCmdKeyShortcuts</div>
<div><span style="font-size:13.3333px">TextEditor (or SmalltalkEditor) class >> #initializeShiftCmdKeyShortcuts</span></div>
<div><span style="font-size:13.3333px"><br>
</span></div>
<div><span style="font-size:13.3333px">Here is a crazy idea: In those editor methods (e.g., #paste), we could add a pragma (e.g. "<userEdit>") and then look for a method activation with that pragma on the stack in Editor >> #userHasEdited. :-D</span></div>
<div><span style="font-size:13.3333px"><br>
</span></div>
<div><span style="font-size:13.3333px">I think we cannot just use PluggableTextMorph >> #hasUnacceptedEdits: to signal that #textEdited: because that would raise too many signals.</span></div>
<div><span style="font-size:13.3333px"><br>
</span></div>
<div><span style="font-size:13.3333px">Or wouldn't it? Hmmm...</span></div>
<div><span style="font-size:13.3333px"><br>
</span></div>
<div><span style="font-size:13.3333px">PluggableTextMorph >> #hasUnacceptedEdits: aBoolean</span></div>
<div><span style="font-size:13.3333px"><br>
</span></div>
<div><span style="font-size:13.3333px">   "..."</span></div>
<div><span style="font-size:13.3333px">   aBoolean ifTrue: [self textEdited: self text]. </span></div>
<div><span style="font-size:13.3333px"><br>
</span></div>
<div><span style="font-size:13.3333px; line-height:1.5">Best,</span></div>
<div><span style="font-size:13.3333px">Marcel</span></div>
<div class="x_mb_sig"></div>
<blockquote class="x_history_container" type="cite" style="border-left-style:solid; border-width:1px; margin-top:20px; margin-left:0px; padding-left:10px">
<p style="color:#AAAAAA; margin-top:10px">Am 18.07.2019 19:13:44 schrieb Christoph Thiede <christoph.thiede@outlook.de>:</p>
<div style="font-family:Arial,Helvetica,sans-serif">Hi all,<br>
<br>
I did not found out whether this is a known bug/limitation: When you press<br>
, or any other shortcut that raises a read-only operation<br>
into a TextMorphForEditView, #textEdited: is called. This is caused by the<br>
"guess editing" in TextMorphForEditView>>#keyStroke:. I think this is an<br>
unwanted behavior as some views might schedule some relevant behavior to any<br>
real text edition. (For example, we are working at a sheet tool which<br>
activates an edit mode when any edit is received. It is irritating to get<br>
the edit mode activated whenever some text is selected via keyboard.)<br>
<br>
I first tried to add another condition to the cheap check<br>
<br>
<br>
<br>
but then, events like Control Paste did not raise a #keyStroke: call. Marcel<br>
proposed the alternative to compare old and new contents. Personally, I<br>
would not find this solution ideal, as it is possible that the view decides<br>
to change its contents when the text is edited, and in this case it would<br>
receive #textEdited: just after the keystroke. (Our sheet tool does so, by<br>
the way. Do you think this is a non-abusing implementation? In our concrete<br>
case, the alternative would be to override both PluggableTextMorphPlus and<br>
TextMorphForEditView.)<br>
<br>
Is there any existing hook to identify the latest modifying event/user<br>
operation that could be used for a cheap check here? As someone who is not<br>
familiar with Morphic-TextSupport, my best idea would be adding a state<br>
variable (wasEdited) to the Editor, resetting it before calling super<br>
keyStroke: and testing it afterwards. In case of TextEditors, it _might_ be<br>
an option to consult its history (?), but that wouldn't be an universal<br>
solution? I do not really find that would be beautiful solutions, and would<br>
welcome any better proposals to learn from them.<br>
<br>
Best,<br>
Christoph<br>
<br>
<br>
<br>
--<br>
Sent from: http://forum.world.st/Squeak-Dev-f45488.html<br>
<br>
</div>
</blockquote>
</div>
</div>
</div>
</body>
</html>