Forum > LCL
TFileNameEdit, TDirectoryEdit (EditBtn)-how to customize behavior OnButtonClick?
max555:
Hello,
Question about TFileNameEdit, TDirectoryEdit controls from EditBtn module.
Linux; FPC 3.2; Lazarus 3.4
Is there any way to suppress/skip/disable standard OpenFile dialog when user clicks on "browse files" button on such controls?
I can use OnButtonClick event to do what is necessary, but then sometimes I need to suppress file selection dialog because file is already selected by my code.
RxTools for Delphi offers OnBeforeDialog event with Action parameter that is very useful in some cases.
As I understand its not possible for Lazaus version of these components?
May be add Action parameter to OnButtonClick event in the future?
Thank you.
jamie:
here is an idea. Scan the control and disable or enable the button?
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TForm1.FileNameEdit1MouseDown(Sender: TObject; Button: TMouseButton; shift: TShiftState; X, Y: Integer);Var B:TSpeedButton; C:TControl; I:Integer;begin For I := 0 To FileNameEdit1.ComponentCount-1 Do Begin If FileNameEdit1.Components[I].ClassName = 'TEditSpeedButton' Then Begin C:= TControl(FileNameEdit1.Components[I]); C.Enabled := False; Break; end; end; end;
That will disable the button when needed. of course you need to enable it at some point.
you can do this when items get selected you don't need to repen.
max555:
Thank you but this does not work. Still standard dialog opens
Sieben:
Create your own descendants and override ButtonClick method. OOP is not about just using components...
jamie:
I think you misunderstood what I intended to show you.
You click in the general left side area to trigger the mouse event, and that code will execute, after which the Editbutton on the right will disable.
I did this using 3.6 laz so unless the class name is different from yours, it should work.
You can print the class names you get somewhere to as it searches the list.
The code I showed you was a test block intended for you to get the idea.
you would need to create a function somewhere to set or unset the button etc.
Navigation
[0] Message Index
[#] Next page