On Sun, Jul 24, 2016 at 02:35:13PM +0200, Yuriy Tymchuk wrote:
Iâve found a partial hack:
whenEdited: aBlock "Set a block to perform when the text wasEddited & the widget entered hasUnacceptedEdits mode"
hasUnacceptedEdits whenChangedDo: [ :val | val ifTrue: aBlock value ]
So now before the text is accepted I can block some other widgets
wtf is whenEdited: :-o There are couple of bugs I've reported last week in regards to this, because it's quite annoying. https://pharo.fogbugz.com/f/cases/18799/TextModel-whenTextChanged-and-whenTe... https://pharo.fogbugz.com/f/cases/18800/TextModel-has-inconsistent-text-chan... I guess whenEdited: should be added to those issues. Btw, what are you trying to do? Because I was playing around with custom styling for my DSL (parsed & highlighted by PetitParser), but got stopped by this same issue. Do you use a similar setup? Could we extrapolate something generically useful from this? Peter
Uko
On 24 Jul 2016, at 14:17, Nicolai Hess <nicolaihess@gmail.com> wrote:
2016-07-24 13:45 GMT+02:00 Yuriy Tymchuk <yuriy.tymchuk@me.com <mailto:yuriy.tymchuk@me.com>>: There is #pendingText to access it, finally found that. Now I want to detect when someone starts typing and do actions (like disable something until the text is accepted). There is whenTextChanged: but itâs not that useful because it checks if the accepted text has changed. Is there a way to check if pendingCode has changed? Or if the model is entering âhasUnacceptedEditsâ?
No :(
I don't think this is possible. You could turn autoAccept to true and listen for set a whenTextChanged block, but of course, you can not display "unaccepted" text anymore, because all text is accepted.
Uko
On 24 Jul 2016, at 12:48, Yuriy Tymchuk <yuriy.tymchuk@me.com <mailto:yuriy.tymchuk@me.com>> wrote:
Cool. Thank you Nicolai. While we are on this, is there an example of how to display the parsing/compilation error as is done in playground?
Uko
On 24 Jul 2016, at 11:37, Nicolai Hess <nicolaihess@gmail.com <mailto:nicolaihess@gmail.com>> wrote:
2016-07-24 11:35 GMT+02:00 Nicolai Hess <nicolaihess@gmail.com <mailto:nicolaihess@gmail.com>>:
2016-07-24 11:14 GMT+02:00 Yuriy Tymchuk <yuriy.tymchuk@me.com <mailto:yuriy.tymchuk@me.com>>: Hi,
at some moment I wrote a super angry comment about Spec. But as there is a big effort put into documentation & improving the framework Iâve decided to give it another try.
And guess what, after 10 min I ran into yet one more problem. I was expecting that it will be tough to have a custom styling for code, but no itâs much simpler: how do I get a text from text model? I type something in, sent #getText to the model => nothing. I expect that the problem is that the text is not accepted⦠Why in the first place a basic text model needs this âacceptâ stuff? What if I have just a dialog where someone types something and submits it? I donât need accepts with orange corners for that.
textmodel autoAccept: true.
I think that youâve got the idea. I just want to build a simple UI and it looks like itâs easier to do it with Morphicâ¦
Cheers. Uko
But I agree, it is not *that* obvious and I think the behavior even changed as we replaced the PluggableTextMorph with Rubric ones - (maybe?)
Anyway, maybe we need a way to distinguish between - get visible text (view get text?) and - get accepted text (model get text?)
nicolai