Quantcast
Channel: SmartClient Forums
Viewing all articles
Browse latest Browse all 4756

moveAbove/bringToFront and Menu

$
0
0
Hello all,

I'm working on smartgwt 4.1, and Firefox.

I'm using methods moveAvobe and bringToFront in Canvas. I've been using this with some elements (buttons, labels, ...) without problems, but I can get effect on Menu elements.

Here you have an example. Clicks on button Front and on the menu, bringToFront the label "Drag Me". The menu doesn't dismiss automatically. But the moveAbove and bringToFront has no effect on the menu.

Cheers,

Miguel

public void onModuleLoad() {
Canvas canvas = new Canvas();

Label bottomLabel = new Label("Bottom");
bottomLabel.setAlign(Alignment.CENTER);
bottomLabel.setShowEdges(true);
bottomLabel.setLeft(60);
bottomLabel.setTop(60);
bottomLabel.setBackgroundColor("lightblue");
canvas.addChild(bottomLabel);

Label topLabel = new Label("Top");
topLabel.setAlign(Alignment.CENTER);
topLabel.setShowEdges(true);
topLabel.setBackgroundColor("pink");
topLabel.setLeft(120);
topLabel.setTop(120);
canvas.addChild(topLabel);

final Label dragWidget = new Label("Drag Me");
dragWidget.setAlign(Alignment.CENTER);
dragWidget.setShowEdges(true);
dragWidget.setBackgroundColor("lightyellow");
dragWidget.setLeft(120);
dragWidget.setTop(0);
dragWidget.setCanDragReposition(true);
dragWidget.setDragAppearance(DragAppearance.TARGET);
canvas.addChild(dragWidget);

final MenuButton menuB = new MenuButton("Menu");
menuB.setShowEdges(true);
menuB.setLeft(0);
menuB.setTop(0);
menuB.setHeight(40);
final Menu menu = new Menu();
menuB.setMenu(menu);
final MenuItem item1 = new MenuItem("menu1");
final MenuItem item2 = new MenuItem("menu2");
menu.addItem(item1);
menu.addItem(item2);
menu.setAutoDismiss(false);
menu.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
System.out.println("menu click");
dragWidget.bringToFront();
dragWidget.moveAbove(menu);
}
});
canvas.addChild(menuB);
VStack vStack = new VStack();
vStack.setLeft(250);
vStack.setMembersMargin(10);

IButton frontButton = new IButton("Front");
frontButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
dragWidget.bringToFront();
}
});
vStack.addMember(frontButton);

IButton backButton = new IButton("Back");
backButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
dragWidget.sendToBack();
}
});
vStack.addMember(backButton);

canvas.addChild(vStack);
canvas.draw();
}

Viewing all articles
Browse latest Browse all 4756

Trending Articles