Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Sapphire » Respond to carriage return in text box
Respond to carriage return in text box [message #1123507] Wed, 02 October 2013 12:37 Go to next message
Paul Kolonay is currently offline Paul Kolonay
Messages: 2
Registered: September 2013
Junior Member
Folks,

Is it possible with Sapphire to execute a handler when a carriage return is entered in a Property Editor? The behavior I am looking for is having a default button pressed when hitting enter in a text entry box.

I tried adding a listener to the property editor but it seems that it only gets called if there is new non whitespace entered in the text box. I also tried using the @Whitespace annotation but that did not appear to matter with respect to what events were generated.

This appears to be basic functionality that exists in SWT land but I just haven't got the Sapphire way of doing this. Perhaps there is an example of this that I have missed.

Thanks for any suggestions

Paul
Re: Respond to carriage return in text box [message #1123704 is a reply to message #1123507] Wed, 02 October 2013 17:06 Go to previous messageGo to next message
Konstantin Komissarchik is currently offline Konstantin Komissarchik
Messages: 845
Registered: July 2009
Senior Member
The behavior you are seeking of activating the default button in the dialog when ENTER is pressed already exists without the developer having to do anything extra. You can see it in the EzBug sample. Either the dialog or the wizard. If the default button is enabled (all validation errors are gone) and if focus is on a field that doesn't have its own ENTER key behavior (like a multi-line text or a list), the default button is activated on ENTER.

I wonder what is different in your setup...
Re: Respond to carriage return in text box [message #1124600 is a reply to message #1123704] Thu, 03 October 2013 14:04 Go to previous messageGo to next message
Paul Kolonay is currently offline Paul Kolonay
Messages: 2
Registered: September 2013
Junior Member
Thanks for the quick and (as always) informative response.

I was using a multi-line box by mistake. It took me a little time to figure out that the @LongString annotation on the property was the trigger for text area creation.

The examples you pointed me to also made me realize that I don't really have a default selection since my implementation is an editor page.

Is it possible to generate an action for the ENTER key when the focus is a text box? Below is my sdef for URL entry and OpenBrowser action. The listener I added only gets called for PartInitializationEvent and PartValidationEvent. I can live with the current behavior but I just wanted to make sure I wasn't overlooking something obvious while getting to know Sapphire.

    <section>
        <label>Browser</label>
        <content>
            <if>
                <condition>${BrowserClosed}</condition>
                <then>
                    <property-editor>
                        <hint>
                            <name>aux.text</name>
                            <value>Enter a valid URL for your application.</value>
                        </hint>
                        <property>Url</property>
                        <documentation>
                            <title>Title</title>
                            <content>Content</content>
                            <topic>
                                <href>html/concepts/getting_started.htm</href>
                                <label>getting_started</label>
                            </topic>
                        </documentation>
                        <listener>UrlEntryListener</listener>
                    </property-editor>
                    <actuator>
                        <action-handler-id>open.browser.handler</action-handler-id>
                        <action-handler>
                            <action>open.browser</action>
                            <id>open.browser.handler</id>
                            <impl>OpenBrowserHandler</impl>
                        </action-handler>
                        <action-id>open.browser</action-id>
                        <action>
                            <id>open.browser</id>
                            <label>Open Browser</label>
                        </action>
                        <horizontal-align>right</horizontal-align>
                        <show-label>true</show-label>
                        <style>Sapphire.Actuator.Button</style>
                    </actuator>
                </then>
            </if>
        </content>
        <documentation>
            <title>Browser Documentation</title>
            <content>Browser Documentation Content</content>
            <topic>
                <href>html/concepts/getting_started.htm</href>
                <label>gettting.started</label>
            </topic>
        </documentation>
    </section>
    <image>icons/Lasso.png</image>
</node>
Re: Respond to carriage return in text box [message #1124656 is a reply to message #1124600] Thu, 03 October 2013 15:21 Go to previous message
Konstantin Komissarchik is currently offline Konstantin Komissarchik
Messages: 845
Registered: July 2009
Senior Member
You should be able to define an action with ENTER for key binding and attach action + handler to the property editor, but it looks like ENTER isn't supported by key binding system at the moment. Please open a bug, if you need to get this working.
Previous Topic:Property depending on path property not refreshed after Browse dialog closes
Goto Forum:
  


Current Time: Mon Oct 07 23:22:38 EDT 2013

Powered by FUDForum. Page generated in 0.01565 seconds