Alan Colburn wrote:
> I've got a Memo box and what I'm trying to do is have users be able
> to highlight some text within the memo, press CTRL+SHIFT+S, and then
> do something with the highlighted text. I've got two quick questions
> related to this. First, how does one capture the CTRL-SHIFT-S
> keystroke combination in something like a KeyDown or KeyUp event?

You CAN use the "OnKey*" events for this, trapping a complex keystroke 
looks something like:

procedure TForm1.Memo1Keydown(Sender: TObject;
   var Key: Word; Shift: TShiftState);
begin
   if (Key = Ord('S')) and (Shift = [ssCTRL, ssShift]) then...
end;

But as another poster pointed out, it's much easier to work with Actions.

> For now I've simply been using the Escape key as a substitute. So, if
> ESC is pressed then a begin/end block that works with Memo.SelText
> executes. After the block executes (and the event handler ends), the
> Memo is cleared ... any text that was previously in it, whether
> highlighted or not, goes away. Although I'm not including the method,
> I can step through the code and see that the memo's text is *not*
> cleared because of any sub-routines that I've added.
>
> Do you know why the memo is cleared? And, more importantly, the
> alternate line(s) I should write to simply work with the selected
> text and then return the focus back to the otherwise untouched Memo?

If you're 100% sure you're not setting SelText somewhere then my first 
guess is that something is "typing" into the Memo, which serves to clear 
the selected text.

Post your current key handling code, it will probably show up there.

Stephen Posey
[EMAIL PROTECTED]




This message and its attachments are for the sole use of the intended 
recipient(s) and may contain confidential, 
 proprietary and privileged information. Any unauthorized review, copying, use, 
disclosure or distribution is prohibited. If 
 you are not the intended recipient, please notify the sender immediately by 
replying to the address listed in the From: 
 field and destroy all copies of the original message and its attachments.
_______________________________________________
Delphi mailing list -> [email protected]
http://www.elists.org/mailman/listinfo/delphi

Reply via email to