pivot-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sandro Martini <sandro.mart...@gmail.com>
Subject Re: Prompt: override option click event
Date Fri, 18 May 2012 21:13:43 GMT
Hi,
sorry for no mail today but we are in a vote for the 2.0.2 release these
days (and we are doing many tests on it, to ensure it's ok) ... so we have
to update next week.

Bye,
Sandro
 Il giorno 18/mag/2012 19:55, "mattux" <mattux@hotmail.fr> ha scritto:

> Ok so to add a bit to this:
>
> I tried to override the TerraPromptSkin (TerraExtendedPromptSkin.java)
> class
> so I could have some control on the buttonPressed event.
> Here is an extract of the mock class:
>
>        private ButtonPressListener optionButtonPressListener = new
> ButtonPressListener() {
>                public void buttonPressed(Button button) {
>                        int optionIndex =
> optionButtonBoxPane.indexOf(button);
>                        if (optionIndex >= 0) {
>                                //Prompt prompt = (Prompt)getComponent();
>
>  //prompt.setSelectedOptionIndex(optionIndex);
>                                //prompt.close(true);
>                        }
>                }
>        };
>
>        @Override
>        public void install(Component component) {
>                ExtendedPrompt prompt = (ExtendedPrompt) component;
>                // We backup the options
>                ArrayList options = new ArrayList(prompt.getOptions());
>                // We reset the options so the subclass doesn't create the
> buttons that we
> want to override
>                prompt.getOptions().remove(0, options.getLength());
>                super.install(component);
>                BXMLSerializer bxmlSerializer = new BXMLSerializer();
>                try {
>                        bxmlSerializer.readObject(TerraPromptSkin.class,
> "terra_prompt_skin.bxml");
>                } catch(Exception exception) {
>                        throw new RuntimeException(exception);
>                }
>                optionButtonBoxPane = (BoxPane)
> bxmlSerializer.getNamespace().get("optionButtonBoxPane");
>                // We set the options back and create buttons with our
> custom listeners
>                prompt.setOptions(options);
>                for (Object option : options) {
>                        PushButton optionButton = new PushButton(option);
>
>  optionButton.setStyleName(TerraPromptSkin.class.getPackage().getName() +
> "." + TerraTheme.COMMAND_BUTTON_STYLE);
>                        for (ButtonPressListener listener :
> optionButton.getButtonPressListeners()) {
>
>  optionButton.getButtonPressListeners().remove(listener);
>                        }
>
>  optionButton.getButtonPressListeners().add(optionButtonPressListener);
>                        optionButtonBoxPane.add(optionButton);
>                }
>        }
>
> When putting a breakpoint in both the listener (at int optionIndex =
> optionButtonBoxPane.indexOf(button);) and the install function (at
> ExtendedPrompt prompt = (ExtendedPrompt) component;). The code definitely
> goes through my install function. However, if I click on the prompt button,
> it doesn't stop at my listener breakpoint and the prompt just closes.
>
> Any ideas on what I'm doing wrong here would be much appreciated.
>
> Regards,
> Matt
>
> --
> View this message in context:
> http://apache-pivot-users.399431.n3.nabble.com/Prompt-override-option-click-event-tp3999325p4001268.html
> Sent from the Apache Pivot - Users mailing list archive at Nabble.com.
>

Mime
View raw message