UberEatsClone icon indicating copy to clipboard operation
UberEatsClone copied to clipboard

Make Entire Dish Preview clickable

Open shannah opened this issue 5 years ago • 0 comments

This might be a bug in CN1's lead component handling, but the DishPreview isn't firing the event when the user clicks on the image. CN1 is having trouble handling the nested lead components (DishPreview's lead component is the nested MultiButton, but MultiButton itself is a container with a lead component).

To work around this problem, create a dummy Button in the DishPreview and set it as the lead component. Then add the actionListener to both the multibutton and the dummy button.

E.g.

Button lead = new Button();
lead.setVisible(false);
add(BorderLayout.SOUTH, lead);
setLeadComponent(lead);
....

$(lead, dishPreview).addActionListener(evt -> {
            evt.consume();
            ActionNode action = viewNode.getInheritedAction(DISH_CLICKED);
            if (action != null) {
                System.out.println("DISH_CLICKED action fired");
                action.fireEvent(entity, DishPreview.this);
            }
        });

shannah avatar Jan 25 '21 13:01 shannah