mouse button and keyboard interaction

For questions and postings not covered by the other forums
ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

mouse button and keyboard interaction

Postby ConvertFromOldNGs » Fri Aug 07, 2009 12:38 pm

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?

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: mouse button and keyboard interaction

Postby ConvertFromOldNGs » Fri Aug 07, 2009 12:38 pm

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

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: mouse button and keyboard interaction

Postby ConvertFromOldNGs » Fri Aug 07, 2009 12:38 pm

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

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: mouse button and keyboard interaction

Postby ConvertFromOldNGs » Fri Aug 07, 2009 12:38 pm

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


Return to “General Discussion”

Who is online

Users browsing this forum: No registered users and 38 guests