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
> 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)
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" <jmm...@yahoo.com> wrote in message
news:1102364483.2...@z14g2000cwz.googlegroups.com...
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
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
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
BTW - I added your solution to the page, it is interesting.
Thank, but I've tried your solution. It work from a SingleThreaded
Menu. But fails from a Frame.
I went back and tested it again just in case. I've got a simple App
with 2 menus (SingleThreaded and Frame) and one window procedure. I
switch from Single to Threaded Frame to verify. When testing I'm
putting the code in ThisWindow.TakeSelected for the Selected Field.
Currently I'm only testing with ABC.
>From a Frame with your method the highlighting always stops at the
location of the cursor when the mouse is used.
My API method above works, but it moves the cursor.
Which I don't like. Other than that it seems to work fine.
If you have another idea let me know and I will give it a try. I would
prefer your solution because then I would not need to move the cursor.
Do you know how to calculate the actual length of the text. That would
improve what I'm doing.
Thanks,
Jim Mumford