Hi,
SC_SNAPSHOT-2011-04-10/EVAL Deployment
Internet Explorer 8.0
When running the below test case in Internet Explorer 8, I am unable to click
the icon that will show our custom dialog. In FireFox 3.6.16 it works perfectly.
Repo case, click in the testitem => icon is shown.
Move mouse pointer over icon and click icon => icon is hidden again!
Regards,
Bart
SC_SNAPSHOT-2011-04-10/EVAL Deployment
Internet Explorer 8.0
When running the below test case in Internet Explorer 8, I am unable to click
the icon that will show our custom dialog. In FireFox 3.6.16 it works perfectly.
Repo case, click in the testitem => icon is shown.
Move mouse pointer over icon and click icon => icon is hidden again!
Regards,
Bart
Code:
public class Standalone implements EntryPoint {
private static Canvas masterPanel = null;
public void onModuleLoad() {
//masterPanel should be a Layout
masterPanel = new Canvas();
masterPanel.setHeight100();
masterPanel.setWidth100();
masterPanel.setStyleName("pageBackground"); //background style from skin
masterPanel.addChild(testCase1());
masterPanel.draw();
}
public DynamicForm testCase1() {
DataSource dataSource = new DataSource();
DataSourceField myTextField = new DataSourceField();
myTextField.setName("textField");
myTextField.setTitle("textField");
myTextField.setType(new MyTextType());
myTextField.setEditorType(new MyTextEditor());
dataSource.setFields(myTextField);
DynamicForm form = new DynamicForm();
form.setHeight(170);
form.setWidth(500);
form.setDataSource(dataSource);
return form;
}
}
public static class MyTextType extends SimpleType {
public MyTextType() {
super("myTextType", FieldType.ANY);
}
}
private class MyTextEditor extends TextItem {
private Dialog dialog;
private FormItem currentItem;
/*
* Setting the picker to show causes an onBlur event. So we would be stuck in a loop.
*/
private boolean ignoreFocusInBlurEvent = false;
/*
* The onFocus might actually trigger a lot of events for the full duration of having focus. So omit unnecessary redraws()s.
*/
private boolean isPickerShowing = false;
public MyTextEditor() {
super();
setChangeOnKeypress(false);
setSelectOnFocus(true);
setValidateOnExit(true);
FormItemIcon icon = new FormItemIcon();
icon.setSrc("[SKIN]/actions/edit.png");
icon.setTabIndex(-1);
setIcons(icon);
setShowIcons(false);
// If user clicks in this field
addFocusHandler(new FocusHandler() {
public void onFocus(FocusEvent event) {
if (isPickerShowing) return;
ignoreFocusInBlurEvent = true;
event.getItem().setShowIcons(true);
event.getItem().getContainerWidget().redraw();
event.getItem().focusInItem();
isPickerShowing = true;
ignoreFocusInBlurEvent = false;
}
});
//If focus gone
addBlurHandler(new BlurHandler() {
public void onBlur(BlurEvent event) {
if (!isPickerShowing) return;
if (ignoreFocusInBlurEvent) return;
event.getItem().setShowIcons(false);
event.getItem().redraw();
isPickerShowing = false;
}
});
addIconClickHandler(new IconClickHandler() {
public void onIconClick(IconClickEvent event) {
// get global coordinates of the clicked picker icon
Rectangle iconRect = getIconPageRect(event.getIcon());
Object source = event.getSource();
if (source != null) {
currentItem = event.getItem();
// show the picker dialog
if (iconRect != null) {
showDialog(iconRect.getLeft(), iconRect.getTop());
} else {
showDialog(EventHandler.getX(), EventHandler.getY());
}
}
}
});
}
private void showDialog(int left, int top) {
if (dialog == null) {
createDialog(currentItem, currentItem.getValue());
}
// don't put dialog outside pageRight
if (left + dialog.getWidth() > Page.getWidth()) {
left = Page.getWidth() - dialog.getWidth() - 5; // margin
if (left < 0)
left = 5;
}
// don't put dialog outside pageBottom
if (top + dialog.getHeight() > Page.getHeight()) {
top = Page.getHeight() - dialog.getHeight() - 5; // margin
if (top < 0)
top = 5;
}
dialog.moveTo(left, top);
dialog.show();
}
private void createDialog(final FormItem item, final Object enteredValue) {
dialog = new Dialog();
dialog.setDismissOnEscape(true); // close on esc
dialog.setDismissOnOutsideClick(true); // close when clicked outside
dialog.setAutoCenter(true);
dialog.setIsModal(true);
dialog.setShowEdges(false);
dialog.setBorder("1px solid #555555"); // show a line around the box
dialog.setShowHeader(false);
dialog.setShowToolbar(false);
dialog.setAutoSize(true);
dialog.setBackgroundColor("#FFFFFF"); // without this you could see true
// the dialog in some browsers
final DynamicForm dialogForm = new DynamicForm();
dialogForm.setAutoFocus(true);
final TextItem txtRefAmount = new TextItem("input");
txtRefAmount.setChangeOnKeypress(false);
txtRefAmount.setValidateOnChange(true);
txtRefAmount.setValidateOnExit(true);
txtRefAmount.setValidators(new IsFloatValidator());
txtRefAmount.setSelectOnFocus(true);
txtRefAmount.setTitle("Amount");
txtRefAmount.setValue(enteredValue);
dialogForm.addSubmitValuesHandler(new SubmitValuesHandler() {
public void onSubmitValues(SubmitValuesEvent event) {
dialog.hide();
}
});
final ButtonItem btnItem = new ButtonItem("Ok");
btnItem.addClickHandler(new com.smartgwt.client.widgets.form.fields.events.ClickHandler() {
public void onClick(com.smartgwt.client.widgets.form.fields.events.ClickEvent event) {
dialogForm.submit();
}
});
btnItem.setColSpan(2);
btnItem.setAlign(Alignment.RIGHT);
btnItem.setWidth(100);
dialogForm.setItems(txtRefAmount, btnItem);
dialog.addItem(dialogForm);
dialog.setVisibility(Visibility.HIDDEN);
dialog.draw();
}
}
}
Comment