jemmyhatta Posted January 2, 2015 Share Posted January 2, 2015 Hello friends, how to make set focus on button messagedlg when the dialog show? Link to comment Share on other sites More sharing options...
Sherzod Posted January 2, 2015 Share Posted January 2, 2015 Hello friends, how to make set focus on button messagedlg when the dialog show? Hi, If I understand correctly, one of the ways (If you do not create a "Message" programmatically on JS) ... /* * Ext.MessageBox internal button array: * * [0] 'OK' * * [1] 'Yes' * * [2] 'No' * * [3] 'Cancel' */ 1. procedure TMainForm.UniFormCreate(Sender: TObject); begin UniSession.AddJS('Ext.override(Ext.MessageBox, {defaultButton: 3});'); end; 2. Can also be changed in runtime: procedure TMainForm.UniButton8Click(Sender: TObject); begin UniSession.AddJS('Ext.override(Ext.MessageBox, {defaultButton: 2});'); MessageDlg('mbYesNoCancel', mtConfirmation, mbYesNoCancel, DCallBack4); end; Try .. Best regards. 1 Link to comment Share on other sites More sharing options...
jemmyhatta Posted January 5, 2015 Author Share Posted January 5, 2015 Hi, If I understand correctly, one of the ways (If you do not create a "Message" programmatically on JS) ... /* * Ext.MessageBox internal button array: * * [0] 'OK' * * [1] 'Yes' * * [2] 'No' * * [3] 'Cancel' */ 1. procedure TMainForm.UniFormCreate(Sender: TObject); begin UniSession.AddJS('Ext.override(Ext.MessageBox, {defaultButton: 3});'); end; 2. Can also be changed in runtime: procedure TMainForm.UniButton8Click(Sender: TObject); begin UniSession.AddJS('Ext.override(Ext.MessageBox, {defaultButton: 2});'); MessageDlg('mbYesNoCancel', mtConfirmation, mbYesNoCancel, DCallBack4); end; Try .. Best regards. Hi, Thanks for telling me the way. It works! Another question then, how it works if not in the mainform? Can you tell me how to do that too? Let say in UniForm1. I already tried to call unisession from other form but it can't be called even when i already added "use unit" into that uniform1. Anything i missed, or there's some trick for that case? Thanks in advanced, best regards. Link to comment Share on other sites More sharing options...
Sherzod Posted January 5, 2015 Share Posted January 5, 2015 uses //..., Dialogs, uniGUIApplication; Link to comment Share on other sites More sharing options...
jemmyhatta Posted January 6, 2015 Author Share Posted January 6, 2015 Thanks... It works. Link to comment Share on other sites More sharing options...
jemmyhatta Posted January 7, 2015 Author Share Posted January 7, 2015 I want to share my experience related to this matter. Something odd but true, insignificant but annoying. Please check the pictures below: Picture 1 (Listing Code Ok.png): This is part of the coding in the event "OnExit". If the program executed, the steps becoming like this: Picture 2 (Step1.jpg): The module to view the data where people could see and choose the relevant data for editing and/or deleted. After got the necessary data, I double click the data which is located on that grid. Picture 3 (Step2.jpg): The selected data will move to the module which function is to edit or delete. then, click the button "hapus" ("delete"), then all selected data will appear to each columns according to the data before delete. Cursor set focus is on the "NoBukti" column and then if we do some "OnExit" from the "NoBukti" column the "messagedlg" will be appeared. Picture 4 (Step3.png):The dialog is appeared, and set focus on button messagedlg. Success.Picture 5 (Listing Code Trouble.jpg)I add up some code on that part.Picture 6 (Step 3 Trouble.png) After adding some codes there, I re-run the applications again like the sequences before, but the result I've got is the dialog is not set focus on button messagedlg. The codes I've added up more or less have same function, just move the data to the designated columns. Is it bugs or what? Please update me, let me know where to fix and how to do that. Thank you. Best Regards NB: While waiting for your kind reply, I'll still searching the solution for this problem myself. Link to comment Share on other sites More sharing options...
Sherzod Posted January 7, 2015 Share Posted January 7, 2015 Hi, Can you make a simple test case ?! Best regards. Link to comment Share on other sites More sharing options...
jemmyhatta Posted January 26, 2015 Author Share Posted January 26, 2015 Hello, Sorry for the late reply, I've got many things to do lately (works). Below I attached source code of my simple test case. Please review and correct me, where I've made mistakes? Or, is there some sort of magic trick on handling the MessageDlg? Thanks in advance. Best Regards. Tes.zip Link to comment Share on other sites More sharing options...
Sherzod Posted January 26, 2015 Share Posted January 26, 2015 Hi, Try: procedure TMainForm.BSaveClick(Sender: TObject); begin if strlen(pchar(trim(EKode.Text)))=0 then begin UniSession.AddJS('Ext.override(Ext.MessageBox, {defaultButton: 0});'); Messagedlg('Kolom Kode Harus Di isi !!!', mtwarning, [mbOk], CallBack); //EKode.SetFocus; <----------------- Exit; end; if strlen(pchar(trim(ENama.Text)))=0 then begin UniSession.AddJS('Ext.override(Ext.MessageBox, {defaultButton: 0});'); Messagedlg('Kolom Name Harus Di isi !!!', mtwarning, [mbOk], CallBack); //ENama.SetFocus; <----------------- Exit; end; ..... Best regards. Link to comment Share on other sites More sharing options...
jemmyhatta Posted January 26, 2015 Author Share Posted January 26, 2015 Is it the proper way to use messagedlg? Below that command, nothing else than "exit" function? May I know the reason why messagedlg on unigui behaves like that? imho(in my humble opinion), the future development of unigui could see this matter too. Best Regards, Link to comment Share on other sites More sharing options...
opxopx Posted December 6, 2017 Share Posted December 6, 2017 Frustating.. Hi, Try: procedure TMainForm.BSaveClick(Sender: TObject); begin if strlen(pchar(trim(EKode.Text)))=0 then begin UniSession.AddJS('Ext.override(Ext.MessageBox, {defaultButton: 0});'); Messagedlg('Kolom Kode Harus Di isi !!!', mtwarning, [mbOk], CallBack); //EKode.SetFocus; <----------------- Exit; end; if strlen(pchar(trim(ENama.Text)))=0 then begin UniSession.AddJS('Ext.override(Ext.MessageBox, {defaultButton: 0});'); Messagedlg('Kolom Name Harus Di isi !!!', mtwarning, [mbOk], CallBack); //ENama.SetFocus; <----------------- Exit; end; ..... Best regards. I got same problem.. that code sometimes work, sometimes no action.. Finally i use native JS "alert" to display message box Link to comment Share on other sites More sharing options...
Recommended Posts