Highlighting Text Upon Entry into Text Field - Motif

This is a discussion on Highlighting Text Upon Entry into Text Field - Motif ; Is there a resource that will automatically highlight the text in a non-empty text field so that if the user starts typing the contents will immediately be replaced? Does this have to be done with code? If so, a pointer ...

+ Reply to Thread
Results 1 to 8 of 8

Thread: Highlighting Text Upon Entry into Text Field

  1. Highlighting Text Upon Entry into Text Field


    Is there a resource that will automatically highlight the text in a non-empty
    text field so that if the user starts typing the contents will immediately be
    replaced? Does this have to be done with code? If so, a pointer would be
    appreciated.

    TIA!

    --
    Jake Colman

    Principia Partners LLC Phone: (201) 209-2467
    Harborside Financial Center Fax: (201) 946-0320
    902 Plaza Two E-mail: colman@ppllc.com
    Jersey City, NJ 07311 www.principiapartners.com

  2. Re: Highlighting Text Upon Entry into Text Field



    Jake Colman wrote:
    >
    > Is there a resource that will automatically highlight the text in a non-empty
    > text field so that if the user starts typing the contents will immediately be
    > replaced? Does this have to be done with code? If so, a pointer would be
    > appreciated.
    >
    > TIA!
    >
    > --
    > Jake Colman
    >
    > Principia Partners LLC Phone: (201) 209-2467
    > Harborside Financial Center Fax: (201) 946-0320
    > 902 Plaza Two E-mail: colman@ppllc.com
    > Jersey City, NJ 07311 www.principiapartners.com


    Use XmTextSetSelection() in an event handler. You yave two choices for
    the event handler: FocusIn event (FocusChangeMask) or EnterNotify
    (EnterWindowMask). You need to decide which of these events should cause
    the text to be selected.
    --
    Fred L. Kleinschmidt
    Boeing Associate Technical Fellow
    Technical Architect, Common User Interface Services
    M/S 2R-94 (206)544-5225

  3. Re: Highlighting Text Upon Entry into Text Field

    Jake Colman wrote:
    >
    > Is there a resource that will automatically highlight the text in a non-empty
    > text field so that if the user starts typing the contents will immediately be
    > replaced?


    You could define a XmNfocusCallback that points to a routine that does:

    XmTextGetLastPosition, and then a XmTextSetSelection from position 0 to the
    last position.

  4. Re: Highlighting Text Upon Entry into Text Field

    >>>>> "FLK" == Fred L Kleinschmidt writes:

    >> Jake Colman wrote:
    >>
    >> Is there a resource that will automatically highlight the text in a
    >> non-empty text field so that if the user starts typing the contents
    >> will immediately be replaced? Does this have to be done with code? If
    >> so, a pointer would be appreciated.
    >>


    FLK> Use XmTextSetSelection() in an event handler. You yave two choices
    FLK> for the event handler: FocusIn event (FocusChangeMask) or EnterNotify
    FLK> (EnterWindowMask). You need to decide which of these events should
    FLK> cause the text to be selected.

    Fred,

    I only want the text highlighted when the user tabs into the field and for
    the field that gets initial focus when the window is opened. If the user
    clicks into the field, it should not highlight. A double-click on the field
    should highlight.

    How do you suggest I deal with this?

    Thanks!

    ....Jake

    --
    Jake Colman

    Principia Partners LLC Phone: (201) 209-2467
    Harborside Financial Center Fax: (201) 946-0320
    902 Plaza Two E-mail: colman@ppllc.com
    Jersey City, NJ 07311 www.principiapartners.com

  5. Re: Highlighting Text Upon Entry into Text Field

    >>>>> "Jake" == Jake Colman writes:

    >>>>> "FLK" == Fred L Kleinschmidt writes:
    >>> Jake Colman wrote:
    >>>
    >>> Is there a resource that will automatically highlight the text in a
    >>> non-empty text field so that if the user starts typing the contents
    >>> will immediately be replaced? Does this have to be done with code? If
    >>> so, a pointer would be appreciated.
    >>>


    FLK> Use XmTextSetSelection() in an event handler. You yave two choices
    FLK> for the event handler: FocusIn event (FocusChangeMask) or EnterNotify
    FLK> (EnterWindowMask). You need to decide which of these events should
    FLK> cause the text to be selected.

    Jake> Fred,

    Jake> I only want the text highlighted when the user tabs into the field
    Jake> and for the field that gets initial focus when the window is opened.
    Jake> If the user clicks into the field, it should not highlight. A
    Jake> double-click on the field should highlight.

    Jake> How do you suggest I deal with this?

    Jake> Thanks!

    Noone replied to this so I thought I'd try again.

    How can I distinguish between tabbing into a text field and any other form of
    moving the focus to the text field. Only when the user uses the tab key to
    move focus do I want to select the field's contents.

    --
    Jake Colman

    Principia Partners LLC Phone: (201) 209-2467
    Harborside Financial Center Fax: (201) 946-0320
    902 Plaza Two E-mail: colman@ppllc.com
    Jersey City, NJ 07311 www.principiapartners.com

  6. Re: Highlighting Text Upon Entry into Text Field

    Jake Colman wrote:
    > How can I distinguish between tabbing into a text field and any other form of
    > moving the focus to the text field. Only when the user uses the tab key to
    > move focus do I want to select the field's contents.



    The XmNfocusCallback provides an XmAnyCallbackStruct which has a pointer to
    the event that triggered the focus. By checking the event, you should be able
    to determine if it is a tab or mouse. (haven't checked the specifics though).

  7. Re: Highlighting Text Upon Entry into Text Field

    >>>>> "FLK" == Fred L Kleinschmidt writes:

    FLK> Jake Colman wrote:
    >>
    >> Is there a resource that will automatically highlight the text in a
    >> non-empty text field so that if the user starts typing the contents
    >> will immediately be replaced? Does this have to be done with code? If
    >> so, a pointer would be appreciated.
    >>


    FLK> Use XmTextSetSelection() in an event handler. You yave two choices
    FLK> for the event handler: FocusIn event (FocusChangeMask) or EnterNotify
    FLK> (EnterWindowMask). You need to decide which of these events should
    FLK> cause the text to be selected.

    I need to limit this to only highlight the text if focus moved to the field
    via the tab key. The FocusIn and EnterNotify events can tell me that focus
    has moved to the widget but cannot tell me whether it got there via a tab
    key. A keypress event handler can trap that the tab key was pressed but it
    will be triggered on the widget from where focus is moving out of.

    I guess I can set a flag in a keypress handler to indicate that a tab key was
    pressed and have a focusin handler check that flag. But I'm concerned that
    the flag may not bet properly cleared in all cases, for example, a mouse
    click to move the focus. Hmmmm. Maybe the focusin event can always clear
    that flag.

    Any suggestions?

    --
    Jake Colman

    Principia Partners LLC Phone: (201) 209-2467
    Harborside Financial Center Fax: (201) 946-0320
    902 Plaza Two E-mail: colman@ppllc.com
    Jersey City, NJ 07311 www.principiapartners.com

  8. Re: Highlighting Text Upon Entry into Text Field

    >>>>> "Jake" == Jake Colman writes:

    FLK> Use XmTextSetSelection() in an event handler. You yave two choices
    FLK> for the event handler: FocusIn event (FocusChangeMask) or EnterNotify
    FLK> (EnterWindowMask). You need to decide which of these events should
    FLK> cause the text to be selected.

    Jake> I need to limit this to only highlight the text if focus moved to
    Jake> the field via the tab key. The FocusIn and EnterNotify events can
    Jake> tell me that focus has moved to the widget but cannot tell me
    Jake> whether it got there via a tab key. A keypress event handler can
    Jake> trap that the tab key was pressed but it will be triggered on the
    Jake> widget from where focus is moving out of.

    Jake> I guess I can set a flag in a keypress handler to indicate that a
    Jake> tab key was pressed and have a focusin handler check that flag. But
    Jake> I'm concerned that the flag may not bet properly cleared in all
    Jake> cases, for example, a mouse click to move the focus. Hmmmm. Maybe
    Jake> the focusin event can always clear that flag.

    I did end up using a global flag to slove the problem.

    I have a KeyPress/ButtonPress event handler that sets a flag when a TAB key
    is pressed. The flag is cleared if any other key or a mouse button is
    pressed.

    I have a FocusChanged event handler that selects the text upon FocusIn if the
    Tab flag is true. On FocsuOut it clears the selection.

    Thanks!

    --
    Jake Colman

    Principia Partners LLC Phone: (201) 209-2467
    Harborside Financial Center Fax: (201) 946-0320
    902 Plaza Two E-mail: colman@ppllc.com
    Jersey City, NJ 07311 www.principiapartners.com

+ Reply to Thread