View Full Version : modaldialog bug
matthewjones
10-28-2005, 12:12 AM
I've come across a problem with modaldialog.
It doesn't prevent the user from editting text in other text and edittext components, as per the example below. This was posted to the forum some time back, but there was no response.
Does anyone have any a workaround, or know of any progress towards a fix?
Obviously in this state, the modaldialog is not actually modal!
Thanks,
Matthew Jones.
<canvas height="300">
<simplelayout axis="x" spacing="20"/>
<modaldialog name="mydialog" width="300" height="200">
<text>Are you really sure you want to do something?</text>
<view align="right" layout="axis:x; spacing:20">
<button onclick="parent.parent.close()">Cancel</button>
<button onclick="parent.parent.close()" isdefault="true">OK</button>
</view>
<simplelayout spacing="5"/>
</modaldialog>
<button onclick="canvas.mydialog.open()">Open Dialog</button>
<edittext text="1234"></edittext>
<inputtext text="texto"></inputtext>
</canvas>
papas
10-28-2005, 12:07 PM
Gee...
What a bug indeed! I have noticed it the very first day I tried laszlo, in one of the examples.
I never got really mad about it, but since you have the same problem, I decided to give it a look.
So. What I came up with, is a simple event listener (Is that the name? I dont speak good english), to make it disabled when a modal dialog exists and the edittext IS NOT on that modal dialog.
So, here the code. You have to place it in your lps/components/lz/edittext.lzx, right after the attributes declarations.
<method name="disableme" reference="LzModeManager" event="onmode" args="args">
_enabled=false;
if (args == null){
_enabled=true;
}else{
var myname=args['name'];
var daddy = parent;
while(daddy != canvas){
if (myname == daddy.name){
_enabled=true;
break;
}
daddy=daddy.parent;
}
}
_showEnabled();
</method>
I also include a test case, where you can see 2 modal dialogs, one on top of the other, and the edittexts that are disabled, are these that DO NOT reside on the frontmost window.
EXAMPLE:
<canvas width="700" height="500" debug="true">
<modaldialog name="a" width="200" height="200">
<button onclick="parent.close()">close</button>
<button x="50" onclick="canvas.b.open()">open</button>
<edittext y="30" name="aa">asdf</edittext>
</modaldialog>
<modaldialog name="b" width="100" height="100">
<button onclick="parent.close()">close</button>
<edittext name="bb" y="30" >asdf</edittext>
</modaldialog>
<edittext name="aa0">asdf</edittext>
<button y="30" onclick="canvas.a.open()">open</button>
</canvas>
have fun, and keep the spirit free!!!!
Vagelis Papadogiannakis
PS: Is there a way for a post to keep the formating? I included tabs in this one, but it displays flat!
matthewjones
10-28-2005, 08:38 PM
Hey, you're good at this!
Thanks - it works a treat.
Matthew Jones.
I'm only new at this.
A question comes to mind from your solution.
What happens when I install a new version of the Laszlo software?
Do I need to keep track of all such changes I make to lps/components files and then re-apply the changes after installing a software update?
I'm thinking yes - is that right?
Thanks again.
papas
10-29-2005, 01:28 AM
Believe me, you should not be any tired for doing this once a month or once every 2 months! I should do it every 2 days (I dont, actualy, I never keep any changes I did in the lps folder)
After all you can just do it a custom class extending the edittext, and use it with a diferent name
have fun, and keep the spirit free!!!!
Vagelis Papadogiannakis
Kallen
02-22-2007, 07:25 PM
The bug described in the OP still seems to exist. Has there been, or will there be, a fix?
Has anyone found a different way around it?
In studying the code suggested by papas, I don't see how the method, "disableme" ever gets called. The code, itself, is clever -- but don't methods have to be called in order to work?
At first I thought it might be overriding an existing method, but I couldn't find one.
Anyone?
vBulletin® v3.8.4, Copyright ©2000-2012, Jelsoft Enterprises Ltd.