Jump to content


Photo

how to make set focus on button messagedlg when the dialog show?


  • Please log in to reply
10 replies to this topic

#1 jemmyhatta

jemmyhatta

    Member

  • uniGUI Subscriber
  • PipPip
  • 45 posts

Posted 02 January 2015 - 03:23 AM

Hello friends,  how to make set focus on button messagedlg when the dialog show?


  • 0

#2 Delphi Developer

Delphi Developer

    Advanced Member

  • Moderators
  • 3648 posts

Posted 02 January 2015 - 06:11 PM

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

#3 jemmyhatta

jemmyhatta

    Member

  • uniGUI Subscriber
  • PipPip
  • 45 posts

Posted 05 January 2015 - 06:00 AM

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.


  • 0

#4 Delphi Developer

Delphi Developer

    Advanced Member

  • Moderators
  • 3648 posts

Posted 05 January 2015 - 07:28 AM

uses //..., 
Dialogs, uniGUIApplication;

  • 0

#5 jemmyhatta

jemmyhatta

    Member

  • uniGUI Subscriber
  • PipPip
  • 45 posts

Posted 06 January 2015 - 02:10 AM

Thanks... It works.


  • 0

#6 jemmyhatta

jemmyhatta

    Member

  • uniGUI Subscriber
  • PipPip
  • 45 posts

Posted 07 January 2015 - 02:35 AM

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.

 

Attached Files


  • 0

#7 Delphi Developer

Delphi Developer

    Advanced Member

  • Moderators
  • 3648 posts

Posted 07 January 2015 - 10:32 AM

Hi,
 
Can you make a simple test case ?!
 
Best regards.

  • 0

#8 jemmyhatta

jemmyhatta

    Member

  • uniGUI Subscriber
  • PipPip
  • 45 posts

Posted 26 January 2015 - 05:27 AM

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.

Attached Files

  • Attached File  Tes.zip   6.11MB   18 downloads

  • 0

#9 Delphi Developer

Delphi Developer

    Advanced Member

  • Moderators
  • 3648 posts

Posted 26 January 2015 - 05:53 AM

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.


  • 0

#10 jemmyhatta

jemmyhatta

    Member

  • uniGUI Subscriber
  • PipPip
  • 45 posts

Posted 26 January 2015 - 07:26 AM

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,


  • 0

#11 opxopx

opxopx

    Newbie

  • Members
  • Pip
  • 1 posts

Posted 06 December 2017 - 04:38 AM

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


  • 0




1 user(s) are reading this topic

1 members, 0 guests, 0 anonymous users


    jparaujo