Recent

Author Topic: TDirectoryEdit with OnAfterDialog event?  (Read 1033 times)

dsiders

  • Hero Member
  • *****
  • Posts: 1594
TDirectoryEdit with OnAfterDialog event?
« on: March 06, 2026, 11:25:50 pm »
After fiddling with TDirectoryEdit for a while, I find myself in need of a way to determine whether the dialog for the control changed anything after the dialog was executed. TDirectoryEdit does not provide a ModalResult for the dialog execution. I thought the Boolean value used in RunModal might be useful in an OnAfterDialog(ASuccess: Boolean) event - where ASuccess is the Boolean value captured in RunDialog. It could be called as the last action in RunDialog.

TDirectoryEdit is not present in VCL - so it shouldn't be a compatibility issue (not that really matters to me).

Have I missed something else that might already be available? OnChange is key-by-key changes during direct input. OnAcceptDir only happens if the dialog was successfully executed (not cancelled). I'm primarily interested in the fact that it was cancelled.

Opinions?

jamie

  • Hero Member
  • *****
  • Posts: 7661
Re: TDirectoryEdit with OnAfterDialog event?
« Reply #1 on: March 06, 2026, 11:33:04 pm »
The "Modified" property does not work for you?

P.s.
 How about the OnAcceptDirectory?

Jamie
« Last Edit: March 06, 2026, 11:40:38 pm by jamie »
The only true wisdom is knowing you know nothing

dsiders

  • Hero Member
  • *****
  • Posts: 1594
Re: TDirectoryEdit with OnAfterDialog event?
« Reply #2 on: March 07, 2026, 12:20:23 am »
The "Modified" property does not work for you?

No it doesn't.

How about the OnAcceptDirectory?

See above.

Bart

  • Hero Member
  • *****
  • Posts: 5713
    • Bart en Mariska's Webstek
Re: TDirectoryEdit with OnAfterDialog event?
« Reply #3 on: March 07, 2026, 04:46:47 pm »
I'm primarily interested in the fact that it was cancelled.

That makes me curious: why?
What's your use case?

Bart

dsiders

  • Hero Member
  • *****
  • Posts: 1594
Re: TDirectoryEdit with OnAfterDialog event?
« Reply #4 on: March 07, 2026, 06:14:36 pm »
I'm primarily interested in the fact that it was cancelled.
That makes me curious: why?
What's your use case?

I'm trying to build a navigation panel for TShellListView. It's a composite of TToolbar and TDirectoryEdit. Click on the client area of the toolbar and it displays a directory edit. Run the dialog for the directory edit and it returns to the toolbar. There is an event for successful completion of the dialog (OnAcceptDir) but nothing for cancellation. Both conditions should return to the toolbar.

See attached.




JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4709
  • I like bugs.
Re: TDirectoryEdit with OnAfterDialog event?
« Reply #5 on: March 07, 2026, 06:57:34 pm »
Maybe a "OnCancelButton" event should be added. It should be in the base class and available for other similar controls, too.
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

dsiders

  • Hero Member
  • *****
  • Posts: 1594
Re: TDirectoryEdit with OnAfterDialog event?
« Reply #6 on: March 07, 2026, 08:19:12 pm »
Maybe a "OnCancelButton" event should be added. It should be in the base class and available for other similar controls, too.

I may be interested in the Cancel action... but I think it would be more generally useful for after dialog execution. Actually, it would be better if RunDialog returned a modal result instead of a Boolean that could be signalled to an OnAfterDialog event. But I'm not trying to redesign the whole control.

Maybe TDirectoryEditEx for ExCtrls. Just thinkin' out loud...

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4709
  • I like bugs.
Re: TDirectoryEdit with OnAfterDialog event?
« Reply #7 on: March 07, 2026, 09:37:24 pm »
Actually, it would be better if RunDialog returned a modal result instead of a Boolean that could be signalled to an OnAfterDialog event.
Currently procedure TDirectoryEdit.RunDialog;
does not return anything but TCommonDialog.Execute inside it return a Boolean.
A new OnAfterDialog event could have a ModalResult parameter indeed. However OnAcceptDirectory is still needed not to break existing code. Thus a new OnCancelDialog event could suffice.
Something like in the attached patch.
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

Bart

  • Hero Member
  • *****
  • Posts: 5713
    • Bart en Mariska's Webstek
Re: TDirectoryEdit with OnAfterDialog event?
« Reply #8 on: March 07, 2026, 11:36:30 pm »
For consistency it then should be added to each and every TCustomAbstractGroupedEdit derived control that has it's Buddy exectue aome kind of dialog.
I don't think I really like the idea.

Bart

dsiders

  • Hero Member
  • *****
  • Posts: 1594
Re: TDirectoryEdit with OnAfterDialog event?
« Reply #9 on: March 08, 2026, 12:24:25 am »
For consistency it then should be added to each and every TCustomAbstractGroupedEdit derived control that has it's Buddy exectue aome kind of dialog.

TCustomAbstractGroupedEdit might be a little too far up the ancestry. Not every TCustomAbstractGroupedEdit descendant runs a dialog. TCustomEditButton might be a better candidate - but I'm not sure if all of those actually run a dialog.

I don't think I really like the idea.

I wasn't asking for the change. Just tossing an idea around. I'm more than likely going to create my own descendant.

Bart

  • Hero Member
  • *****
  • Posts: 5713
    • Bart en Mariska's Webstek
Re: TDirectoryEdit with OnAfterDialog event?
« Reply #10 on: March 08, 2026, 01:04:32 am »
I'm more than likely going to create my own descendant.

Yeah, probably the way to go for now.

Bart

 

TinyPortal © 2005-2018