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: 244
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: 145
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: 2164
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: 244
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: 2164
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: 244
Joined: Fri Feb 25, 2011 12:08 am


Return to MUI Royale

Who is online

Users browsing this forum: No registered users and 1 guest