PDA

View Full Version : dotnet question and a case question


Hobbs
10-23-2009, 08:52 PM
I'm working on a richtextbox and i have 2 question

how can i tell if both shift and enter are pressed during a keydown method call?

So if a user hits enter do one thing, and the if they hold shift and hit enter do another. I would prefer to do this all in .net

and then ..

if i am using a case of expression, how can i "fall through" effect like you can get in c++

here's the function


on EditBox keyDown arg do
(
pressed = arg.keycode

case pressed of
(
(pressed.Enter ):
(pressed.Return):
(
EditBox.SelectedText = "\n"
)
(pressed.Tab):
(
EditBox.SelectedText = "\t";
)
)
)


I'd like the pressed.Enter and pressed.Return to have the same clause with out duplicating it.

Thanks

denisT
10-23-2009, 09:12 PM
I'm working on a richtextbox and i have 2 question

how can i tell if both shift and enter are pressed during a keydown method call?

So if a user hits enter do one thing, and the if they hold shift and hit enter do another. I would prefer to do this all in .net

and then ..

if i am using a case of expression, how can i "fall through" effect like you can get in c++

here's the function


on EditBox keyDown arg do
(
pressed = arg.keycode

case pressed of
(
(pressed.Enter ):
(pressed.Return):
(
EditBox.SelectedText = "\n"
)
(pressed.Tab):
(
EditBox.SelectedText = "\t";
)
)
)



I'd like the pressed.Enter and pressed.Return to have the same clause with out duplicating it.

Thanks

System.Windows.Forms.KeyEventArgs has property "Shift"... just check it:

if arg.Shift and (arg.keyCode == arg.keyCode.Enter) ...
or
case arg.keyCode of
(
(arg.keyCode.Enter) : if arg.Shift do ...
)

denisT
10-23-2009, 09:18 PM
if i am using a case of expression, how can i "fall through" effect like you can get in c++


you can't fall through in MXS case expression.
but you use case without a test expression :


case of
(
((arg.keycode == arg.keycode.enter) or (arg.keycode == arg.keycode.tab)) : ...
)

Hobbs
10-23-2009, 09:18 PM
sweet, worked like a charm.


haha, was posting when you wrote.

Thanks again

denisT
10-23-2009, 09:20 PM
see above :)

CGTalk Moderation
10-23-2009, 09:20 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.