Notifications
Clear all

[Closed] dotnet question and a case question

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 = "
"
  		)
  		(pressed.Tab):
  		(
  			EditBox.SelectedText = "	";
  		)
  	)
  )
    
I'd like the pressed.Enter and pressed.Return to have the same clause with out duplicating it.

Thanks
4 Replies

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 …
)

1 Reply
(@denist)
Joined: 1 year ago

Posts: 0

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)) : ...
)

sweet, worked like a charm.

haha, was posting when you wrote.

Thanks again

see above