unit AddresslistEditor; { Editor for the addresslist an editor at the location of the value field self: when the enter key is pressed set the new value on the provided memoryrecord when the edit box loses focus apply the change and close the editor (OnEditorClose(sender: Editor)) when escape is pressed, do not apply the change and just close (OnEditorClose) When the edit box is clicked between the create time and create time+GetDoubleClickTime(), return an "OnDoubleclick(sender: Editor)" When doubleclicked return an OnDoubleClick When the up or down key is pressed, apply the change, and send an event that the entry is changed (OnEntryChange(sender: editor; direction)) If a dropdown list is implemented, make this an combobox and feed it the list on creation owner: when the view is scrolled/collapsed/expanded the owner should call UpdatePosition, or destroy the editor(optionally applying the current value) } {$mode delphi} interface uses windows, Classes, SysUtils, ComCtrls, Controls, StdCtrls, MemoryRecordUnit, Graphics, LCLType; type TAddressListEditor=class(TCustomEdit) private fOnEditorClose: TNotifyEvent; fOnDoubleClick: TNotifyEvent; fmemrec: TMemoryrecord; edited: boolean; starttime: dword; protected procedure DoClose; procedure DblClick; override; procedure MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override; procedure KeyDown(var Key: Word; Shift: TShiftState); override; procedure TextChanged; override; procedure DoExit; override; public procedure UpdatePosition(left: integer); constructor create(owner: TTreeView; memrec: TMemoryrecord; left: integer); destructor destroy; override; published property memrec: TMemoryrecord read fmemrec; property OnEditorClose: TNotifyEvent read fOnEditorClose write fOnEditorClose; property OnDblClick; //: TNotifyEvent read fOnDoubleclick write fOnDoubleClick; end; implementation uses addresslist; procedure TAddressListEditor.DblClick; begin edited:=false; DoClose; inherited DblClick; end; procedure TAddressListEditor.MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin // if gettickcount