Texteditor haschange

Discuss GUI programming with the MUI Royale plugin here

Texteditor haschange

Postby lazi » Thu Aug 24, 2017 9:15 pm

Please help me on how to get every changes from a texteditor?
Here is my example script where only the first keypress in the texteditor triggers "haschanged" event.

Code: Select all
@REQUIRE "muiroyale.hwp"
@DISPLAY {hidden=True}

Function p_EventFunc(msg)
   DebugPrint(msg.class,msg.id,msg.attribute)
   If msg.class="Window" Then End
EndFunction

mainwindow=[[
<?xml version="1.0" encoding="utf-8"?>
<application id="TextCraft" base="TextCraft">

<window AppWindow="true" id="win" title="TextCraft" muiid="MAIN" notify="closerequest; appmessage" sizegadget="True">
   <vgroup>
      <texteditor id="editor"/>
   </vgroup>
</window>
</application>
]]
mui.CreateGui(mainwindow)

InstallEventHandler({MUIRoyale = p_EventFunc})

mui.notify("editor","haschanged",True)

Repeat
   WaitEvent
Forever


Texteditor.mcp 15.48
muimaster.library 21.79 (nightly build)
OS4
User avatar
lazi
 
Posts: 265
Joined: Fri Feb 25, 2011 12:08 am

Re: Texteditor haschange

Postby PEB » Fri Aug 25, 2017 6:54 am

"UndoAvailable" works better with Amigas. ("HasChanged" works better with Windows.)
PEB
 
Posts: 151
Joined: Sun Feb 21, 2010 2:28 am

Re: Texteditor haschange

Postby airsoftsoftwair » Sat Aug 26, 2017 12:50 pm

TextEditor.HasChanged really seems to behave differently on MUI and Windows. On Windows it triggers for every character that changes, on MUI only for the first change. Now the question is which is the better behaviour: Should it trigger just once or for every character that changes? Triggering for every character can be a huge waste of CPU cycles of course so I'm not sure whether this is the best behaviour.

Both lazi and PEB seem to need such a behaviour, though, so maybe you can describe why exactly you want to be notified for every character that changes? I currently can't think of a situation in which such a behaviour is necessary so please elaborate...
User avatar
airsoftsoftwair
 
Posts: 2225
Joined: Fri Feb 12, 2010 3:33 pm
Location: Germany

Re: Texteditor haschange

Postby lazi » Sat Aug 26, 2017 9:20 pm

My current need of haschanged is very simple. I want to know if the content is changed after opening or after last save operation.
I got a notify on the first change and after saving the content this changed state should be cleared somehow to look for the next change.
So there is no need to get every change if I can reset the changed state manually.

According to the notify on every keypress, I can imagine an editor like the good old Amos editor which was formatted the line or comand after every space or enter keypress.
User avatar
lazi
 
Posts: 265
Joined: Fri Feb 25, 2011 12:08 am

Re: Texteditor haschange

Postby airsoftsoftwair » Tue Aug 29, 2017 5:32 pm

lazi wrote:My current need of haschanged is very simple. I want to know if the content is changed after opening or after last save operation.
I got a notify on the first change and after saving the content this changed state should be cleared somehow to look for the next change.
So there is no need to get every change if I can reset the changed state manually.


Hmm, now I'm confused. So why did you ask how to get a notification for every key press? :)

According to the notify on every keypress, I can imagine an editor like the good old Amos editor which was formatted the line or comand after every space or enter keypress.


That's true but implementing syntax highlighting is far too advanced for RapaGUI's text editor class. This will lead to trouble. We'd need a platform-independent, more flexible engine like Scintilla for that.
User avatar
airsoftsoftwair
 
Posts: 2225
Joined: Fri Feb 12, 2010 3:33 pm
Location: Germany

Re: Texteditor haschange

Postby lazi » Fri Sep 08, 2017 10:49 pm

Hmm, now I'm confused. So why did you ask how to get a notification for every key press?

Did I ask it? :)
When I was not able to solve the problem just got the idea that squeezing every changes from the gadget will give a solution. And if one thinks too much in the bad direction can't leave it easily :)

And what do you say? Have you found a good idea for this particular problem?
It is surely a tough task to foresee how evil things the users will do and call it programming :)

Ok forget about the requirements of syntax highlighting. Scintilla is really far better for code editing than current texteditor.mcp.
User avatar
lazi
 
Posts: 265
Joined: Fri Feb 25, 2011 12:08 am

Re: Texteditor haschange

Postby airsoftsoftwair » Sat Sep 30, 2017 12:30 pm

I think I know now why the different behaviour could be a problem: When using the TextEditor.hws example on Amiga, you'll only get one "HasChanged" notification. This leads to the problem that if you modify the text after having saved it, there'll be no more "HasChanged" notifications which is indeed a problem. On Windows, Linux, and Mac OS this isn't a problem because the "HasChanged" events will be generated for every change. That's why I have fixed RapaGUI now to use the same behaviour on AmigaOS too.

Code: Select all
- Fix [Amiga]: TextEditor.HasChanged triggers for every change now, not only for the first one; this
  makes the Amiga version consistent to the behaviour of the Windows, Linux, and Mac OS versions of
  RapaGUI; requires TextEditor.mcc 15.48 or better
User avatar
airsoftsoftwair
 
Posts: 2225
Joined: Fri Feb 12, 2010 3:33 pm
Location: Germany

Re: Texteditor haschange

Postby lazi » Sun Oct 01, 2017 8:52 pm

Hmmm. But what about MUIRoyale? :)
As I said it should not notify on every keypress.
But what is it good for if only the first keypress is notified?
The best way IMHO would be the ability to reset the modified state.
User avatar
lazi
 
Posts: 265
Joined: Fri Feb 25, 2011 12:08 am

Re: Texteditor haschange

Postby airsoftsoftwair » Mon Oct 02, 2017 4:39 pm

lazi wrote:Hmmm. But what about MUIRoyale? :)
As I said it should not notify on every keypress.
But what is it good for if only the first keypress is notified?
The best way IMHO would be the ability to reset the modified state.


That's already possible. Just reset it manually and you'll get a new notification on the next keypress, i.e. do something like this:

Code: Select all
Switch msg.action
Case "MUIRoyale":
   Switch msg.attribute
   Case "HasChanged":
      mui.set("editor", "nonotify", True, "haschanged", False)
   EndSwitch
EndSwitch


But make sure to use TextEditor 15.48 from here: http://www.airsoftsoftwair.de/binary/tm ... -15.48.lha
User avatar
airsoftsoftwair
 
Posts: 2225
Joined: Fri Feb 12, 2010 3:33 pm
Location: Germany

Re: Texteditor haschange

Postby lazi » Mon Oct 02, 2017 8:48 pm

Ohh, thanks!

I forgot "nonotify", True.

No more problem here, please break it up! Nothing to see here. :)
User avatar
lazi
 
Posts: 265
Joined: Fri Feb 25, 2011 12:08 am


Return to MUI Royale

Who is online

Users browsing this forum: No registered users and 4 guests

cron