Change content of Dialogs at run time via script - Forum

Forum Navigation
You need to log in to create posts and topics.

Change content of Dialogs at run time via script

I mentioned to @luishp that the Dialog facility of VisualNEOWeb would be greatly enhanced if the content of the Containers could be modified at run time via script (before invoking the OpenDialog command).

He told me that he had found a way (albeit a few milliseconds afterwards); so, as per his suggestion, I am creating this post for him to share the solution with the entire community.

Vadim has reacted to this post.
Vadim

Thanks again @gaev :)

When working with Dialogs we need to take into account it sometimes takes some milliseconds for them to appear after we use the OpenDialog command. So imagine you have placed a Container object into a Dialog and want to execute this code:

OpenDialog "NewDialog"
SetObjectHTML "Container1" "Hello world!"

It will fail due to the Container1 doesn't exists yet when the SetObjectHTML command is executed.
To fix it, add a small delay just like this:

OpenDialog "NewDialog"
Wait 200
  SetObjectHTML "Container1" "Hello world!"
EndWait

 

@luishp

Thank you for the work around ... it will allow developers to deploy multiple Modal scenarios using a single (or fewer) design time Dialog Containers.

it sometimes takes some milliseconds for them to appear after we use the OpenDialog command.

This brings up the questions ...

1) what happens if the wait time is too small ?

2) what does the user see if it is too long ? ... the previous content for a split second ? ... can the Container be defined (at design time) to be hidden (display = none, opacity = 0, visibility = hidden), and only unhide it after the wait period ? ... of course, for multiple uses, the container would need to be re-hidden before each CloseDialog command.

3) is there a way to 'check' that the container has been rendered ? ... some property perhaps ? ... that way, the wait time does not have to be fixed for all devices (speeds) ?

Of course, this technique opens up the possibilities of changing more than the 'content' of the Dialog container at run time (size, position, colours, fonts, perhaps even dynamic creation of other objects etc.) ... I will play with these ideas tomorrow.

Suggestion for future release ... offer OpenDialogCustom/CloseDialogCustom that supports a subroutine call 'before OpenDialog' and 'before CloseDialog' (similar to that in VisualNEOWin); then, the developer does not have to be concerned with the timing mechanics.

Thanks again.

 

@luishp

Good news ...

1) the Delay technique works as expected; the ability to reuse a single Dialog Container in multiple scenarios opens up a whole new set of Rapid Application Development functions.

2) I found out that you can rely on the display css property to determine if the Dialog Container has been rendered or not (undefined vs. block)

So, using a Timer object, I was also able to get around the fact that different devices might need different amounts of delay.

I will now work on developing a generic OpenDialogPlus command (subroutine or plugin) that developers can invoke to easily deploy a single Dialog Container in multiple scenarios.

 

 

danito, luishp and 2 other users have reacted to this post.
danitoluishppaeonSamuel Vanneste
Open chat
1
Do you need more info?
Hi, do you have any doubt?