Profile Picture

Detecting changes

Posted By NeilTurp 6 Years Ago
Author
Message
NeilTurp
Question Posted 6 Years Ago
View Quick Profile
Forum Newbie

Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)

Group: Forum Members
Last Active: 6 Years Ago
Posts: 0, Visits: 166
Hi
I am writing an app that has to detect if a document has changed, so it can prompt to save or cancel.  I've tried using
.Content.Changed
.Content.ModifiedChanged
.document.Changed
.document.ModifiedChanged
None of them fire reliably as I type, paste, delete, cut.  The first one fires when moving a mouse over the control, or sometimes on a keypress but not always.  Can anyone point me towards what I'm missing?


Nevron Support
Posted 6 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)

Group: Forum Members
Last Active: Last Week
Posts: 3,054, Visits: 4,018
Hi Neil,
You can use the Modified property of the document to check whether the document has changed:
nRichTextViewWithRibbonControl1.Widget.View.document.Modified

If you wish to track when the property is raised you can also subscribe to the document's ModifiedChanged event. Let us know if you meet any problems or have any questions.


Best Regards,
Nevron Support Team



NeilTurp
Posted 6 Years Ago
View Quick Profile
Forum Newbie

Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)

Group: Forum Members
Last Active: 6 Years Ago
Posts: 0, Visits: 166
Excellent thanks.  Just what I needed and no need to monitor it myself.


Tom Galczynski
Posted 5 Years Ago
View Quick Profile
Forum Newbie

Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)

Group: Forum Members
Last Active: 4 Years Ago
Posts: 29, Visits: 87
"If you wish to track when the property is raised you can also subscribe to the document's ModifiedChanged event."
 Hello. I'm trying to handle the above event but I can't seem to get it to fire.  Is there some code examples showing how to set this up so any edit in the UI of the rich edit control can be known? Or some further documentation on exactly when the document's event is fired?
I'm using Vb.Net and am adding a handler in my form:
AddHandler Me.RichTextEdit1.document.ModifiedChanged, AddressOf Me._richTextEdit_TextChanged

Thanks!


Nevron Support
Posted 5 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)

Group: Forum Members
Last Active: Last Week
Posts: 3,054, Visits: 4,018
Hi Tom,
We just checked with the following VB code and it was working correctly:
Public Class Form1
  Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
   AddHandler Me.NRichTextViewControl1.Widget.document.ModifiedChanged, AddressOf Me.EventHandler
  End Sub

  Sub EventHandler(eventArgs As Nevron.Nov.Dom.NEventArgs)
   ' Handle the event.
   MsgBox("Document Changed.")
  End Sub
End Class
When do you subscribe for this event - it may be that at the time when you subscribe the changed flag is already raised - to test this simply reset the flag before you subscribe:
Public Class Form1
  Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
   Me.NRichTextViewControl1.Widget.document.Modified = False
   AddHandler Me.NRichTextViewControl1.Widget.document.ModifiedChanged, AddressOf Me.EventHandler
  End Sub

  Sub EventHandler(eventArgs As Nevron.Nov.Dom.NEventArgs)
   ' Handle the event.
   MsgBox("Document Changed.")
  End Sub
End Class
Also what type is RichTextEdit1?
Let us know if the problem persists...

Best Regards,
Nevron Support Team



Tom Galczynski
Posted 5 Years Ago
View Quick Profile
Forum Newbie

Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)Forum Newbie (0 reputation)

Group: Forum Members
Last Active: 4 Years Ago
Posts: 29, Visits: 87
Perfect.  Just what I needed.  Thanks!



Similar Topics


Reading This Topic