Page 1 of 1

mouse button and keyboard interaction

Posted: Fri Aug 07, 2009 12:38 pm
by ConvertFromOldNGs
by bitsnz >> Sun, 29 Aug 2004 2:41:16 GMT

Hi people

Does anybody have any example code that uses the mouse button (left or right) and a keyboard button as a usable combination to copy text?

i.e
I highlight some text, I hold down the left mouse button (or right) and press the 'S' button (or any button) to indicate that i want this text to be inserted into a particular textbox on another form.

Can anybody help?

Re: mouse button and keyboard interaction

Posted: Fri Aug 07, 2009 12:38 pm
by ConvertFromOldNGs
by cnwjhp1 >> Mon, 30 Aug 2004 4:33:46 GMT

This works - add an Integer attribute called mouseState to the form, then put this code in the TextBox you are copying from (tCmdLine in my example):

tCmdLine_mouseDown(textbox:TextBox input; button:Integer; shift:Integer; x:Real; y:Real) updating;begin

mouseState:=button;
end;

tCmdLine_mouseUp(textbox:TextBox input; button:Integer; shift:Integer; x:Real; y:Real) updating;begin

mouseState:=0;
end;

tCmdLine_keyPress(textbox:TextBox input; keyCharCode:Integer io) updating;begin

if keyCharCode.Character="s" and mouseState>0 then
write textbox.selText;
endif;
end;

Then, if you select text with the left mouse button and press s before letting the mouse button up, the selected text will be displayed. You will need a reference to the other form or textbox to copy it there.

Depending on what you are trying to accomplish though, I would have thought that assigning Ctrl codes would be nicer (for the developer and the user). For example, capture Ctrl+S in keyDown and do the copy that way:

tCmdLine_keyDown(textbox:TextBox input; keyCode:Integer io; shift:Integer) updating;begin

if keyCode=83 and shift=2 then
write textbox.selText;
endif;
end;

Cheers,
John P

Re: mouse button and keyboard interaction

Posted: Fri Aug 07, 2009 12:38 pm
by ConvertFromOldNGs
by bitsnz >> Mon, 30 Aug 2004 8:57:45 GMT

"Depending on what you are trying to accomplish though, I would have thought
that assigning Ctrl codes would be nicer (for the developer and the user)."

As would i but its a preference by the client.

Cheers John

Re: mouse button and keyboard interaction

Posted: Fri Aug 07, 2009 12:38 pm
by ConvertFromOldNGs
by bitsnz >> Mon, 30 Aug 2004 9:20:16 GMT

"Depending on what you are trying to accomplish though, I would have thought
that assigning Ctrl codes would be nicer (for the developer and the user)."

As would i but its a preference by the client.

Cheers John