* * *

Author Topic: [SOLVED] TreeView, Manual canel "Edited" event content and restore orignal?  (Read 329 times)

jamie

  • Jr. Member
  • **
  • Posts: 95
Short of restoring the TEXT content of the node directly from my classes if the
string reported isn't what I will accept.. I need a way the same as using the
ESC key while editing a node in the tree? That will restore the text but, if user does not
hit ESC and I don't accept the entry they put in reported at the OnEdited event, how do
I manually perform the same ESC  to get back what is there?

 currently restoring it is a pain In the butt!.
« Last Edit: October 07, 2017, 10:22:53 pm by jamie »

jamie

  • Jr. Member
  • **
  • Posts: 95
Re: TreeView, Manual canel "Edited" event content and restore orignal?
« Reply #1 on: October 07, 2017, 09:19:23 pm »
I wanted to add that using StoreCurrentSelection and ApplyStoredSelection does not
function inside the OnEDITED event.
 
 I have a function "PopulateView" which would work just fine to restore all of the original
contents, but that too is blocked while the OnEdited event is processing.

 Seems the only fix is to reset the return string.

jamie

  • Jr. Member
  • **
  • Posts: 95
Re: TreeView, Manual canel "Edited" event content and restore orignal?
« Reply #2 on: October 07, 2017, 09:31:13 pm »
Ok, disaster is averted  8-)

 I made a copy of the Node.Text in the OnEditing event first and then in the
OnEDITED event I used that copy to restore it.

Now if I only knew how to change this to SOLVED!

GetMem

  • Hero Member
  • *****
  • Posts: 2325
Re: TreeView, Manual canel "Edited" event content and restore orignal?
« Reply #3 on: October 07, 2017, 09:35:07 pm »
Believe it or not I was typing almost the same solution but you were faster. Another method is to use lazmouseandkeyboard package then simulate a VK_ESCAPE. To mark the thread solved just put [SOLVED] in front of the thread title.

jamie

  • Jr. Member
  • **
  • Posts: 95
Yes, much of us think alike  :-X

The V_ESCAPE won't work in this case because this is taking place within the
OnEDITED event, the S string in the parameter needs to be changed.

 I could do that from outside the control but not in this case, Node.Text is already
changed and out of edit mode when it reaches this event.

 Maybe the control should automatically store the old value if the OnEditing returns
true to allow editing ?
 This would make it easier "GetBeforeEditedNodestring" etc..


Thanks

jamie

  • Jr. Member
  • **
  • Posts: 95
I just found a built in way, I don't know why I didn't see that before....

Smack forehead.

 The Selected proper represents the current editing node, it also holds the original
text. so in the OnEdited event, I can use the S := Selected.Text; so it simple replaces the
text with the original...



GetMem

  • Hero Member
  • *****
  • Posts: 2325
@jamie
You should give VirtualStringTree a try. It's like a TTreeView on steroids.   :)

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus