How to highlight all the Text for a Text field when getting focus by a mouse click? - Clarion

This is a discussion on How to highlight all the Text for a Text field when getting focus by a mouse click? - Clarion ; I followed the direction in the HELP and tried several other things. But can not get it to work properly. 1. From the Window Formatter, RIGHT-CLICK the control and choose Alert from the popup menu. 2. From the Alert Keys ...

+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 11

How to highlight all the Text for a Text field when getting focus by a mouse click?

  1. Default How to highlight all the Text for a Text field when getting focus by a mouse click?

    I followed the direction in the HELP and tried several other things.
    But can not get it to work properly.


    1. From the Window Formatter, RIGHT-CLICK the control and choose Alert
    from the popup menu.
    2. From the Alert Keys dialog, press the Add button.
    3. From the Input Key dialog, CLICK on Left Button in the Mouse group.
    4. Press OK twice to return to the Window Formatter.
    5. From the Window Formatter, RIGHT-CLICK the control and choose Embeds
    from the popup menu.
    6. Add the following code to the EVENT:AlertKey embed point for the
    control:


    IF KEYCODE() = MouseLeft
    SELECT(?,LEN(?{PROP:ScreenText}))
    ?{PROP:SelStart} = 1
    ?{PROP:SelEnd} = LEN(?{PROP:ScreenText})
    END

    The problem I'm am having is after a user selects the field with a LEFT
    MOUSE (it hightlights the entire field proplerly), but then they can
    not change what is highlighted with the LEFT MOUSE (maybe they want to
    change it to only hightlight the 1st couple of characters). I'm trying
    to make this field work like the Address field in MS Internet Explorer.
    So when a person select the field with the mouse it is highlighted and
    then subesequently they can change what is hightlighted by using the
    Left Mouse. It almost works in clarion <g>.

    Does anyone know of a way around to get this to work?

    I've tried everything I can think of an can not get it to work
    properly.

    Thank,

    Jim Mumford


  2. Default Re: How to highlight all the Text for a Text field when getting focusby a mouse click?

    Hi

    > IF KEYCODE() = MouseLeft
    > SELECT(?,LEN(?{PROP:ScreenText}))
    > ?{PROP:SelStart} = 1
    > ?{PROP:SelEnd} = LEN(?{PROP:ScreenText})
    > END
    >
    > The problem I'm am having is after a user selects the field with a LEFT
    > MOUSE (it hightlights the entire field proplerly), but then they can
    > not change what is highlighted with the LEFT MOUSE (maybe they want to
    > change it to only hightlight the 1st couple of characters).

    Well, it isn't strange that it works this way. Your code means that
    every time a user clicks the left mousebutton on the text-field, the
    entire field-contents is selected.

    > So when a person select the field with the mouse it is highlighted and
    > then subesequently they can change what is hightlighted by using the
    > Left Mouse. It almost works in clarion <g>.

    I havn't done this myself. But an idea is to check if the field has
    focus. If the field has focus when the user clicks it, then you doesn't
    want to select all the text, otherwise you do. So the first line of the
    embed-code should maybe be something like:
    IF KEYCODE() = MouseLeft AND FOCUS() = ?MyTextField
    I'm not sure if this is the correct use of the FOCUS command, check the
    help! You should probably make sure that the code is before generated
    code, since the click changes the focus. I'm not sure if this works, but
    anyway the idea must be to somehow check for focus, before deciding to
    select the text. If you can't get it to work with FOCUS or something
    similar, consider using a variable Loc:HasFocus that you turn "on" in
    your selection-code above and "off" on the LooseFocus event (I think it
    is called that).

    Best regards

    Kasper

    --
    Besøg mig på nettet: http://www.kaspershjemmeside.dk (in danish)

  3. Default Re: How to highlight all the Text for a Text field when getting focus by a mouse click?

    Hi there,

    You are probably mislead by IE and you interactions with the address field.
    The text in the field is selected not on the mouse left click, but on
    gaining the focus. Have you tried to activate the address field by using the
    TAB key on the keyboard? The result is the same.
    You must do your trick on gaining the focus, not on the mouse click.

    success,
    Ivo Ivanov
    Modest Automatisering B.V.
    Holland


    "JMumf" <jmmfrd@yahoo.com> wrote in message
    news:1102364483.246225.161140@z14g2000cwz.googlegroups.com...
    > I followed the direction in the HELP and tried several other things.
    > But can not get it to work properly.
    >
    >
    > 1. From the Window Formatter, RIGHT-CLICK the control and choose Alert
    > from the popup menu.
    > 2. From the Alert Keys dialog, press the Add button.
    > 3. From the Input Key dialog, CLICK on Left Button in the Mouse group.
    > 4. Press OK twice to return to the Window Formatter.
    > 5. From the Window Formatter, RIGHT-CLICK the control and choose Embeds
    > from the popup menu.
    > 6. Add the following code to the EVENT:AlertKey embed point for the
    > control:
    >
    >
    > IF KEYCODE() = MouseLeft
    > SELECT(?,LEN(?{PROP:ScreenText}))
    > ?{PROP:SelStart} = 1
    > ?{PROP:SelEnd} = LEN(?{PROP:ScreenText})
    > END
    >
    > The problem I'm am having is after a user selects the field with a LEFT
    > MOUSE (it hightlights the entire field proplerly), but then they can
    > not change what is highlighted with the LEFT MOUSE (maybe they want to
    > change it to only hightlight the 1st couple of characters). I'm trying
    > to make this field work like the Address field in MS Internet Explorer.
    > So when a person select the field with the mouse it is highlighted and
    > then subesequently they can change what is hightlighted by using the
    > Left Mouse. It almost works in clarion <g>.
    >
    > Does anyone know of a way around to get this to work?
    >
    > I've tried everything I can think of an can not get it to work
    > properly.
    >
    > Thank,
    >
    > Jim Mumford
    >




  4. Default Re: How to highlight all the Text for a Text field when getting focus by a mouse click?

    I'm close.

    I've got 3 fields.

    ?EntryField !Used to Select from
    ?TextField
    ?HiddenButton

    ThisWindow.TakeSelected
    OF ?TextField
    IF FOCUS()<>?HiddenButton
    POST(EVENT:Selected,?HidenButton)
    POST(EVENT:Accepted,?HidenButton)
    CYCLE
    END

    ThisWindow.TakeAccepted
    OF ?HiddenButton
    SELECT(?TextField) !Reselect the
    Text Field
    ?TextField{PROP:SelStart} = 1 !Beg of Cusor
    ?TextField{PROP:SelEnd}=LEN(?TextField{PROP:ScreenText}) !End of
    Cursor

    This works when the window is NOT an MDI child.

    When the Window is an MDI child it only selects the portion of the
    field up to the location of the Pointer. So if the pointer is beyond
    the end of the field it will select the whole field.
    Otherwise it only select up to the pointer.

    I want it to always select the whole text field.

    I really need this window to be an MDI child.
    Any idea how to get around this and keep it an MDI Child.

    Jim Mumford


  5. Default Re: How to highlight all the Text for a Text field when getting focus by a mouse click?

    I'm not 100% correct above.

    It is not if it is an MDI child. It is if the window is run from a
    FRAME.

    I just tested it again and it work if I make it the main window and do
    not call it from a FRAME.
    If I call from a FRAME it does not highlight the whole field unless
    selected at the end of the field.
    You would think the the SelEnd take care of it.

    Jim Mumford


  6. Default Re: How to highlight all the Text for a Text field when getting focus by a mouse click?

    I finally got it to work.

    I needed to use a couple of Windows API calls.
    The following seemed to work:

    module('api')
    SetCursorPos (Signed X,Signed Y),BOOL,PASCAL
    ClientToScreen (UNSIGNED Hwnd,LONG),BOOL,PASCAL,RAW
    END

    All code and data under ThisWindow.TakeSelected

    Data:

    GroupXY GROUP,PRE(GroupXY)
    X Signed
    Y Signed
    END

    Code:

    OF ?TextField

    !Place Cursor at End of the Field
    0{PROP:Pixels} = True !Need device units for cursor position
    GroupXY.X = ?TextField{PROP:Xpos}+ ?TextField{PROP:Width}
    GroupXY.Y = ?TextField{PROP:Ypos}+ ?TextField{PROP:Height}/2
    0{PROP:Pixels} = False !Set device Unit back to normal
    ReturnVal#=ClientToScreen(WINDOW{PROP:HANDLE},Address(GroupXY))
    !API
    ReturnVal#=SetCursorPos(GroupXY.X,GroupXY.Y) !API

    !Highlight Text in Field
    ?TextField{PROP:SelStart} = 1
    ?TextField{PROP:SelEnd} = LEN(?TextField{PROP:ScreenText})

    Sure would be nice if we could do this a little easier.

    Jim Mumford


  7. Default Re: How to highlight all the Text for a Text field when getting focus by a mouse click?

    I finally got it to work.

    I needed to use a couple of Windows API calls.
    The following seemed to work:

    module('api')
    SetCursorPos (Signed X,Signed Y),BOOL,PASCAL
    ClientToScreen (UNSIGNED Hwnd,LONG),BOOL,PASCAL,RAW
    END

    All code and data under ThisWindow.TakeSelected

    Data:

    GroupXY GROUP,PRE(GroupXY)
    X Signed
    Y Signed
    END

    Code:

    OF ?TextField

    !Place Cursor at End of the Field
    0{PROP:Pixels} = True !Need device units for cursor position
    GroupXY.X = ?TextField{PROP:Xpos}+ ?TextField{PROP:Width}
    GroupXY.Y = ?TextField{PROP:Ypos}+ ?TextField{PROP:Height}/2
    0{PROP:Pixels} = False !Set device Unit back to normal
    ReturnVal#=ClientToScreen(WINDOW{PROP:HANDLE},Address(GroupXY))
    !API
    ReturnVal#=SetCursorPos(GroupXY.X,GroupXY.Y) !API

    !Highlight Text in Field
    ?TextField{PROP:SelStart} = 1
    ?TextField{PROP:SelEnd} = LEN(?TextField{PROP:ScreenText})

    Sure would be nice if we could do this a little easier.

    Jim Mumford


  8. Default Re: How to highlight all the Text for a Text field when getting focus by a mouse click?

    I finally got it to work.

    I needed to use a couple of Windows API calls.
    The following seemed to work:

    module('api')
    SetCursorPos (Signed X,Signed Y),BOOL,PASCAL
    ClientToScreen (UNSIGNED Hwnd,LONG),BOOL,PASCAL,RAW
    END

    All code and data under ThisWindow.TakeSelected

    Data:

    GroupXY GROUP,PRE(GroupXY)
    X Signed
    Y Signed
    END

    Code:

    OF ?TextField

    !Place Cursor at End of the Field
    0{PROP:Pixels} = True !Need device units for cursor position
    GroupXY.X = ?TextField{PROP:Xpos}+ ?TextField{PROP:Width}
    GroupXY.Y = ?TextField{PROP:Ypos}+ ?TextField{PROP:Height}/2
    0{PROP:Pixels} = False !Set device Unit back to normal
    ReturnVal#=ClientToScreen(WINDOW{PROP:HANDLE},Address(GroupXY))
    !API
    ReturnVal#=SetCursorPos(GroupXY.X,GroupXY.Y) !API

    !Highlight Text in Field
    ?TextField{PROP:SelStart} = 1
    ?TextField{PROP:SelEnd} = LEN(?TextField{PROP:ScreenText})

    Sure would be nice if we could do this a little easier.

    Jim Mumford


  9. Default Re: How to highlight all the Text for a Text field when getting focus by a mouse click?

    I finally got it to work.

    I needed to use a couple of Windows API calls.
    The following seemed to work:

    module('api')
    SetCursorPos (Signed X,Signed Y),BOOL,PASCAL
    ClientToScreen (UNSIGNED Hwnd,LONG),BOOL,PASCAL,RAW
    END

    All code and data under ThisWindow.TakeSelected

    Data:

    GroupXY GROUP,PRE(GroupXY)
    X Signed
    Y Signed
    END

    Code:

    OF ?TextField

    !Place Cursor at End of the Field
    0{PROP:Pixels} = True !Need device units for cursor position
    GroupXY.X = ?TextField{PROP:Xpos}+ ?TextField{PROP:Width}
    GroupXY.Y = ?TextField{PROP:Ypos}+ ?TextField{PROP:Height}/2
    0{PROP:Pixels} = False !Set device Unit back to normal
    ReturnVal#=ClientToScreen(WINDOW{PROP:HANDLE},Address(GroupXY))
    !API
    ReturnVal#=SetCursorPos(GroupXY.X,GroupXY.Y) !API

    !Highlight Text in Field
    ?TextField{PROP:SelStart} = 1
    ?TextField{PROP:SelEnd} = LEN(?TextField{PROP:ScreenText})

    Sure would be nice if we could do this a little easier.

    Jim Mumford


  10. Default Re: How to highlight all the Text for a Text field when getting focu

    There is a simpler solution on clarinfoundry at
    http://www.clarionpublisher.com/site...a-d53e4f5fa9f0

    BTW - I added your solution to the page, it is interesting.


+ Reply to Thread
Page 1 of 2 1 2 LastLast

Similar Threads

  1. Set focus on First text field, if any
    By Application Development in forum Javascript
    Replies: 17
    Last Post: 09-01-2007, 06:06 PM
  2. Highlight and De-highlight text on mouse-over
    By Application Development in forum Javascript
    Replies: 5
    Last Post: 09-21-2006, 03:55 AM
  3. Re: text field focus and placement of cursor
    By Application Development in forum Perl
    Replies: 0
    Last Post: 04-19-2006, 01:29 AM
  4. Re: text field focus and placement of cursor
    By Application Development in forum Perl
    Replies: 0
    Last Post: 04-18-2006, 08:17 PM
  5. How to highlight the currently selected text on mouse event
    By Application Development in forum Adobe Acrobat
    Replies: 0
    Last Post: 02-10-2006, 06:52 AM