Hi there,

I'm new to this GWT stuff, and am trying to create a cascading
calendar along the lines of a menu with child menus.

So far I've knocked the following together, but the first child of the
VerticalPanel does not get any of mouse-events. If you uncomment the
line below so that there is a "dummy" first-child Widget, the mouse-
listener fires.

---------------------------------------------------
public class CalendarWidget extends PopupPanel {

        private DateTimeFormat yearValue = DateTimeFormat.getFormat("yyyy");
        private String[] months = { "Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };

        private Panel debugPanel;

        public CalendarWidget(Date startDate, Date endDate) {
                super(true, false);
                int startYear = Integer.parseInt(yearValue.format(startDate));
                int endYear = Integer.parseInt(yearValue.format(endDate));

                int size = (endYear - startYear) + 1;
                VerticalPanel yearPanel = new VerticalPanel();
                add(yearPanel);
//              yearPanel.add(new Label("1st child"));
                MouseListener yearListener = new CalendarMouseListener();

                for (int idx = 0; idx < size; idx++) {
                        Label yearLabel = new Label(Integer.toString(startYear 
+ idx));
                        yearLabel.addMouseListener(yearListener);

                        Image image = new 
Image("/velocity/images/email_lbl.gif");
                        image.addMouseListener(yearListener);

                        HorizontalPanel labelPanel = new HorizontalPanel();
                        labelPanel.add(yearLabel);
                        labelPanel.add(image);
                        yearPanel.add(labelPanel);

                }
                debugPanel = new VerticalPanel();
                RootPanel.get().add(debugPanel);
        }

        class CalendarMouseListener extends MouseListenerAdapter {

                @Override
                public void onMouseEnter(Widget sender) {
                        debugPanel.add(new InlineLabel("mouse-enter"));
                }

                @Override
                public void onMouseLeave(Widget sender) {
                        debugPanel.add(new InlineLabel("mouse-leave"));
                }

                @Override
                public void onMouseUp(Widget sender, int x, int y) {
                        debugPanel.add(new InlineLabel("mouse-up:" + x +"," + 
y));
                }
        }
}
------------------------------------------------

An explanation as to what's happening would be gratefully received, as
would an example of the correct pattern to follow to do this as
elegantly as possible.

Best wishes,

Michael

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to