API Review Request for RT-17438

Jeff McDonald deep.blue.6802 at gmail.com
Mon Apr 16 12:15:22 PDT 2012


On Mon, Apr 16, 2012 at 1:31 AM, Martin Sladecek <martin.sladecek at oracle.com
> wrote:

> On 04/13/2012 09:30 PM, Jeff McDonald wrote:
>
>> +1 for me.
>>
>> Some random thoughts:
>> - White space typically includes newlines, and the isWhitespace method
>> returns true only for tabs and spaces. The documentations makes it clear
>> what the method does, but it wouldn't be a stretch for a developer to
>> assume that white space includes newlines. ... especially developers that
>> do a lot of work with HTML.
>>
> OK, I think we can also add Enter to the whitespace category.


Richard posted a much more detailed email about whitespace. The list he
included is more comprehensive, but the bulk of those characters aren't
 KeyCodes so they don't fall into the scope of this class and feature.
After scanning over the KeyCode class the KeyCode.ENTER (I'm guessing that
the RETURN and ENTER keys map to the same KeyCode) is the only one that
should be added.


>  - "FunctionKey" is more common usage than "FunctionalKey"
>>
> Right, thanks.
>
>  - 10 key numeric keypads typically map arrow keys on to the 2 (Down
>> Arrow),
>> 4 (Left Arrow), 6 (Right Arrow), 8 (Up arrow) keys. Do these keys return
>> true for isArrowKey()?
>
> There are separate keycodes for them depending on the numlock status
> (KP_LEFT, KP_RIGHT, ... or NUMPAD0, NUMPAD1, ...).


Your initial proposal already answered this question. The javadoc comments
are nice and clear regarding which KeyCodes included and which ones aren't.
Disregard my suggestion.

>

>
>> Make the methods public so that a method such as isWhitespace could be
>> made
>> to detect newlines. Extendability allows the methods to be overridden for
>> other things such as custom keyboards or internationalized keyboards.
>>
> Not sure what you mean, there are already public, but KeyCode is an enum,
> so you can't extend from it.
>

I meant to say to make the to make them non-final rather than "not public",
however, enums can't be extended so my suggestion doesn't fit. Please
disregard this suggestion as well.

Cheers,
Jeff


> -Martin
>
>>
>> Cheers,
>> Jeff
>>
>> On Fri, Apr 13, 2012 at 12:31 AM, Martin Sladecek<
>> martin.sladecek at oracle.com>  wrote:
>>
>>  Hello,
>>>
>>> JIRA: http://javafx-jira.kenai.com/****browse/RT-17438<http://javafx-jira.kenai.com/**browse/RT-17438>
>>> <http://**javafx-jira.kenai.com/browse/**RT-17438<http://javafx-jira.kenai.com/browse/RT-17438>
>>> >
>>>
>>>
>>> The JIRA requests methods for key classification on KeyEvent class, like
>>>
>>> KeyEvent.isFunctionKey() //F1, F2, F3, ..., F24
>>>
>>> KeyEvent.isArrowKey() //UP, DOWN, LEFT, RIGHT.
>>>
>>>
>>> I propose to have these methods on KeyCode class (enum), where they are
>>> more natural and can be used anywhere the KeyCode objects are present
>>> (e.g.
>>> KeyCodeCombination class).
>>> So in case of the keyEvent, the calls would look like:
>>>
>>> ev.getCode().isArrowKey()
>>>
>>>
>>> The list of propsed KeyCode methods:
>>>
>>> /**
>>>     * Functional keys like F1, F2, etc...
>>>     * @return true if this key code corresponds to a functional key
>>>     */
>>>    public final boolean isFunctionalKey()
>>>
>>>    /**
>>>     * Navigation keys are arrow keys and Page Down, Page Up, Home, End
>>>     * @return true if this key code corresponds to a navigation key
>>>     */
>>>    public final boolean isNavigationKey()
>>>
>>>    /**
>>>     * Left, right, up, down keys (including the keypad arrows)
>>>     * @return true if this key code corresponds to an arrow key
>>>     */
>>>    public final boolean isArrowKey()
>>>
>>>    /**
>>>     * Keys that could act as a modifier
>>>     * @return true if this key code corresponds to a modifier key
>>>     */
>>>    public final boolean isModifierKey()
>>>
>>>    /**
>>>     * All keys with letters
>>>     * @return true if this key code corresponds to a letter key
>>>     */
>>>    public final boolean isLetterKey()
>>>
>>>    /**
>>>     * All Digit keys (including the keypad digits)
>>>     * @return true if this key code corresponds to a digit key
>>>     */
>>>    public final boolean isDigitKey()
>>>
>>>    /**
>>>     * All keys on the keypad
>>>     * @return true if this key code corresponds to a keypad key
>>>     */
>>>    public final boolean isKeypadKey()
>>>
>>>    /**
>>>     * Space and tab
>>>     * @return true if this key code corresponds to a whitespace key
>>>     */
>>>    public final boolean isWhitespaceKey()
>>>
>>>    /**
>>>     * All multimedia keys (channel up/down, volume control, etc...)
>>>     * @return true if this key code corresponds to a media key
>>>     */
>>>    public final boolean isMediaKey()
>>>
>>>
>>> Thanks,
>>> -Martin
>>>
>>>
>>>
>


More information about the openjfx-dev mailing list