Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: How can I do modal forms/popup dialogs for Mobile with XE8/Delphi?


This question is answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 9 - Last Post: Jan 13, 2018 8:26 AM Last Post By: Steve Jordi Threads: [ Previous | Next ]
Free Dorfman

Posts: 139
Registered: 2/4/12
How can I do modal forms/popup dialogs for Mobile with XE8/Delphi?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 9, 2015 4:46 PM
How can I do modal forms/popup dialogs for Mobile with XE8/Delphi?

I've spent the better part of 6 hours now looking into this.

Where - in the entirety of the internet - is one simple, complete, working example of this? Or sufficient docs?

-Thanks
##############
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: How can I do modal forms/popup dialogs for Mobile with XE8/Delphi?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 9, 2015 5:25 PM   in response to: Free Dorfman in response to: Free Dorfman
Free wrote:

How can I do modal forms/popup dialogs for Mobile with XE8/Delphi?

Android does not support modal forms. This is discussed on Embarcadero's
DocWiki:

FMX.Forms.TCommonCustomForm.ShowModal
http://docwiki.embarcadero.com/Libraries/Seattle/en/FMX.Forms.TCommonCustomForm.ShowModal

Caution: Modal dialog boxes are not supported in Android apps. Instead of
calling ShowModal, you should call Show, and have the form return and call
your event. We recommend that you not use modal dialogs on either of the
mobile platforms (iOS and Android) because unexpected behavior can result.
Not using modal dialogs eliminates potential problems in debugging and supporting
your mobile apps.

Using FireMonkey Modal Dialog Boxes
http://docwiki.embarcadero.com/RADStudio/Seattle/en/Using_FireMonkey_Modal_Dialog_Boxes

And also on Marco's blog:

Delphi XE5 Anonymous ShowModal and Android
http://blog.marcocantu.com/blog/xe5_anonymous_showmodal_android.html

--
Remy Lebeau (TeamB)
Free Dorfman

Posts: 139
Registered: 2/4/12
Re: How can I do modal forms/popup dialogs for Mobile with XE8/Delphi?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 9, 2015 6:47 PM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
I get all that. I've been looking at that code (and variations of it) all day.

My question is: How do I (let's say) simulate this type of behavior for Android / iOS?

I have a form with 40-ish controls to change the look of something on my main form.

I want it (the change-the-look-form) to be displayed:

*on top of the main form
*without covering the whole screen
*with a border (frame/outline) to make it look "on top"
*with the main form disabled
*until the user clicks [Close]

*and... I'd like to respond to control changes on this form by updating the main form.

Is there a general approach to doing this type of thing (and all things multiple-forms-related) that I am totally missing? Should I not actually have a second FORM for this?

When an app (say Candy Crush - in the hopes that you know its look & feel)
-changes from the map screen to the game screen, is it not actually switching Forms?
-pops up "You failed!" with a [Retry] button, is that not actually a [modal] form?

ALSO: Does anyone know where a good example of using TPopup is? Is this (TPopup) going to help at all with what I'm talking about?

If there was a simple demo app that did these kinds of things, I could get all this info from looking at it.

-Continued Thanks

Free Dorfman

Posts: 139
Registered: 2/4/12
Re: How can I do modal forms/popup dialogs for Mobile with XE8/Delphi?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 11, 2015 1:34 PM   in response to: Free Dorfman in response to: Free Dorfman
Hey All.

I have a path I'm heading down here.

PLEASE tell me if this sounds good - or ridiculous - or something in between.

I am creating my own class: TMopop ("mopup" = modal popup) that descends from TControl.

Whenever I need modal behavior, I am going to (on the MainForm, or the "latest" Mopup):
--set Opacity := 0.8;
--set Enabled := false;

On the CloseBtn of the Mopup, I am going to restore the Opacity & Enabled settings for the "underlying" TControl.

I selected TControl because it's where IContainerObject first appears in the hierarchy.

Does this sound like a decent approach? Again, I am wondering what the "normal" way of doing this is. If there is a "normal" way...

-Many Continuing Thanks
Eli M

Posts: 1,346
Registered: 11/9/13
Re: How can I do modal forms/popup dialogs for Mobile with XE8/Delphi?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 11, 2015 6:25 PM   in response to: Free Dorfman in response to: Free Dorfman
In games and things it's just a semi transparent rectangle or bitmap that covers the screen and then they have a button graphic that sits above that shade layer.

This would be the object hierarchy:
TForm
-TFrame
--TRectangle (Align Contents; Opacity 0.80)
--TImage/TRectangle/TPanel/Your Mini Dialog

Just show and hide the TFrame.

The only reason to use the TFrame is to separate the code of the dialog. Plus then you can re-used the dialog over and over. You also only have to show/hide 1 object instead of 2.

Edited by: Eli M on Sep 11, 2015 6:26 PM
Free Dorfman

Posts: 139
Registered: 2/4/12
Re: How can I do modal forms/popup dialogs for Mobile with XE8/Delphi?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 11, 2015 7:10 PM   in response to: Eli M in response to: Eli M
Eli M wrote:
In games and things it's just a semi transparent rectangle or bitmap that covers the screen and then they have a button graphic that sits above that shade layer.

This would be the object hierarchy:
TForm
-TFrame
--TRectangle (Align Contents; Opacity 0.80)
--TImage/TRectangle/TPanel/Your Mini Dialog

Just show and hide the TFrame.

The only reason to use the TFrame is to separate the code of the dialog. Plus then you can re-used the dialog over and over. You also only have to show/hide 1 object instead of 2.

Edited by: Eli M on Sep 11, 2015 6:26 PM

This may be the "simple" ubiquitous "how is this done for mobile" thing I've been looking for for two full days. I've just started to play with it, but this looks very promising.

Do I Create / Destroy / Show / Hide Frames much like I would Forms?

Thanks & I'll follow up with a quickie to let you know.

Eli -- you rock!

Eli M

Posts: 1,346
Registered: 11/9/13
Re: How can I do modal forms/popup dialogs for Mobile with XE8/Delphi?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 11, 2015 11:15 PM   in response to: Free Dorfman in response to: Free Dorfman
I usually add my frames at design time but as far as I know they behave just like any other control.
Free Dorfman

Posts: 139
Registered: 2/4/12
Re: How can I do modal forms/popup dialogs for Mobile with XE8/Delphi?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 12, 2015 1:39 PM   in response to: Eli M in response to: Eli M
Eli M wrote:
I usually add my frames at design time but as far as I know they behave just like any other control.

Frames is definitely what I was looking for all along. Just that simple.

Does anyone know why Frames don't have different Views like Forms? That'd be helpful. Instead, I'll just use inheritance.
Thomas Riedel

Posts: 6
Registered: 5/7/00
Re: How can I do modal forms/popup dialogs for Mobile with XE8/Delphi?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 7, 2018 7:11 AM   in response to: Free Dorfman in response to: Free Dorfman
procedure TForm1.Info(txt: string);
begin
TThread.Synchronize(nil, procedure
begin
mres := 0;
btnrun.Visible := false;
label1.Text := txt;
edit1.visible := false;
btnyes.visible := false;
btnNo.visible := false;
btnOK.visible := true;
show;
end);
while mres = 0 do sleep (100);
end;

function TForm1.prompt(txt: string): string;
begin
TThread.Synchronize(nil, procedure
begin
mres := 0;
edit1.visible := true;
edit1.text := '';
btnrun.Visible := false;
label1.Text := txt;
btnyes.visible := false;
btnNo.visible := false;
btnOK.visible := true;
show;
end);
while mres = 0 do sleep(100);
result := edit1.Text;
end;

procedure TForm1.Timer1Timer(Sender: TObject);
begin
//rootnode.run(rootnode);
//timer1.Enabled := false;
end;

function TForm1.yes(txt: string): boolean;
begin
TThread.Synchronize(nil, procedure
begin
btnrun.Visible := false;
label1.Text := txt;
edit1.visible := false;
btnyes.visible := true;
btnNo.visible := true;
btnOK.visible := false;
show;
end);
mres := 0;
show;
while mres = 0 do sleep(100);
result := mres = mryes;
end;

The above code works great and make my form1 modal. Clicking any button will change value of mres, and program execution proceeds. But they must be called from a background thread ( task). Problem solved.

Steve Jordi

Posts: 111
Registered: 4/19/98
Re: How can I do modal forms/popup dialogs for Mobile with XE8/Delphi?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 13, 2018 8:26 AM   in response to: Thomas Riedel in response to: Thomas Riedel
http://www.delphifeeds.com/go/t/130342

--
Steve JORDI - MSc in Geophysics/Volcanology

Geneva, Switzerland / Portland, OR, USA
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02