There is also the source to a sample application (hacked-up Hello
sample) as well as a compiled version attached. I have verified that
stacks of modal dialogs behave as expected.
Current caveats:
- On OSX Opera, backspace events in the textbox don't get canceled
as expected so text can be deleted, but not added to.
- Whether or not UI elements are focusable also varies between
browsers. FF does the right thing, IE allows the text box to be
focused, although you can't enter data into it.
diffstat:
DialogBox.java | 27 20 + 7 - 0 !
PopupPanel.java | 76 46 + 30 - 0 !
2 files changed, 66 insertions(+), 37 deletions(-)
--
Bob Vawter
Google Web Toolkit Team
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.google.gwt.sample.hello.client ;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.*;
/**
* HelloWorld application.
*/
public class Hello implements EntryPoint {
public void onModuleLoad() {
HorizontalPanel h = new HorizontalPanel();
Button modal = new Button("Modal", new ClickListener() {
public void onClick(Widget sender) {
createDialog(false, true).show();
}
});
Button modalAutoHide = new Button("Modal + autohide", new ClickListener() {
public void onClick(Widget sender) {
createDialog(true, true).show();
}
});
Button nonModal = new Button("non-Modal", new ClickListener() {
public void onClick(Widget sender) {
createDialog(false, false).show();
}
});
h.add (modal);
h.add(modalAutoHide);
h.add(nonModal);
h.add(new TextBox());
h.add(new CheckBox());
RootPanel.get().add(h);
}
private DialogBox createDialog(boolean autoHide, boolean modal) {
final DialogBox toReturn = new DialogBox(autoHide, modal);
final Button close = new Button("close", new ClickListener() {
public void onClick(Widget w) {
toReturn.hide();
}});
final Button modal2 = new Button("Create modal", new ClickListener() {
public void onClick(Widget w) {
createDialog(false, true).show();
}});
VerticalPanel p = new VerticalPanel();
p.add(new Label("Value of modal: " + modal));
p.add(close);
p.add(modal2);
toReturn.setWidget(p);
toReturn.setText("text title");
return toReturn;
}
}
There isn't a popup layer per-se unless the developer adds z-index CSS
rules, so I'm wary of adding that to PopupPanel. It doesn't seem like
the right solution to have the PopupPanel make structural changes to
the DOM beyond creating its own container. I haven't yet investigated
browser-specific alternatives to capturing/disabling focus, so it may
just be another method to add to the existent PopupImpl deferred
binding classes.
Do the contributors think it would be worthwhile to add a dedicated
GlassPanel for 1.4? It would behave in the manner that Fred describes
and would have the usual well-known CSS rule names to allow for the
cool effects.
That's true if they're in the same stacking context. The attached
file shows two div's that appear before and after the "glass panel" in
the DOM order.
This should appear underneathThis will appear on topThis is the glass panel.This will appear on top
The attached patch amends PopupPanel to listen for Event.ONFOCUS
events to blur any widgets not contained by the PopupPanel that get
focus. This makes the app work like you would expect in IE.
Dialog Demos:
http://www.asquare.net/gwttk/apps/demo/Demo.html#dialogs
On Apr 20, 10:14 am, "Joel Webber" <j...@google.com> wrote:
> Fred,
>
> Thanks for the info. I'm glad you've already worked through this so I don't
> have to :)
>
> I also seem to recall someone already having implemented this, but can't
> remember where. Anyone remember?
>
> Thanks,
> joel.
>
> > > On 4/19/07, BobV < b...@google.com> wrote:
>
> > > > On 4/18/07, Fred Sauer <f...@allen-sauer.com> wrote:
> > > > > Just as an implementation point: my experience has been that you do
> > > > not need
> > > > > z-index to accomplish this. Browsers draw the elements in DOM order
> > > > (which
> > > > > is what we expect). So, popup panel always end up on top, without
> > > > > necessitating a z-index. Similarly adding a glass panel and then
> > > > adding a
> > > > > popup panel should automatically layer the two just right.
>
> > > > That's true if they're in the same stacking context. The attached
> > > > file shows two div's that appear before and after the "glass panel" in
> > > > the DOM order.
>
> > > > --
> > > > Bob Vawter
> > > > Google Web Toolkit Team
>
> > > > This should appear underneath
> > > > This will appear on top
> > > > This is the glass panel.
> > > > This will appear on top
>
> > --
> > Fred Sauer
> > f...@allen-sauer.com- Hide quoted text -
>
> - Show quoted text -
I added a blur() method to PopupPanel and removed the reference to FocusImpl.
> - 164: Could you add an extra set of parens here, just so I don't go
> cross-eyed trying to remember what it will do (it is, of course, correct as
> is).
Done.
The percentage is calculated with respect to the height of the generated box's containing block. If the height of the containing block is not specified explicitly (i.e., it depends on content height), the value is interpreted like 'auto'.
body{height:100%}
html,body{height:100%}