Recent

Author Topic: Basic Q: in TreeView one can call "aNode.EndEdit". Does Listview has such?  (Read 487 times)

d7_2_laz

  • Hero Member
  • *****
  • Posts: 637
For a plugin running inside Notepad++ i had irregularities with item inplace editors (treeview, listview)
who don't close 'automatically' in all expected cases. Eg. the do Not close when clicking onto another control inside the plugin's docking form, or onto some control outside.

I was able to find some workaround hack for the treeview using "OnMouseLeave": if the mouse goes outside the treeview whilst the node editor is open, then i close it explicitely using "aTreeView.Selected.EndEdit(True);".

Does Listview knows something like "EndEdit" - including 'cancel' parameter - which allows to call such closure from outside via code ?

As listview item editor i use something like this:
https://forum.lazarus.freepascal.org/index.php/topic,54348.msg403726.html#msg403726

Remark: for the ListView, there is a "DoEndEdit(AItem: TListItem, const AValue: String)" procedure. But his behaves quirky in my tests
(it requires a new/changed value for the item's caption - otherwise the item editor keeps open -, that's not wanted).
Lazarus 4.0  FPC 3.2.2 Win10 64bit

jamie

  • Hero Member
  • *****
  • Posts: 6943
Did you try posting a message "WM_CancelMode" to the control ?

P.S.
  Not sure if the LCL processes this, if so then it should be in the Lmessages unit under "LM_CANCELMODE"

Jamie
The only true wisdom is knowing you know nothing

d7_2_laz

  • Hero Member
  • *****
  • Posts: 637
Oh, i wasn't aware of the LM_CANCELMODE message yet, thanks for the idea!

Tried it (sending onto the item's editor handle), before or after the DoEndEdit, or without the latter, but it didn't make a difference ..
Lazarus 4.0  FPC 3.2.2 Win10 64bit

jamie

  • Hero Member
  • *****
  • Posts: 6943
Yawn!
Code: Pascal  [Select][+][-]
  1. procedure TForm1.SpeedButton1Click(Sender: TObject);
  2. begin
  3.  ActiveControl := nil;
  4.  Listview1.Selected := Nil;
  5. end;                                
  6.  

You are most likely moving to a TGraphicsControl which does not change the focus.

The only true wisdom is knowing you know nothing

d7_2_laz

  • Hero Member
  • *****
  • Posts: 637
jamie, and this code to implement for potentially all existing controls (if graphicontrol)?

Most cases here are no graphic controls.
Lazarus 4.0  FPC 3.2.2 Win10 64bit

 

TinyPortal © 2005-2018