Use KeyDown event to show memberlist

SyntaxEditor for Windows Forms Forum

Posted 20 years ago by Steven Liu
Avatar
I would like to use CRTL-SPACE to bring up memberlist. Since I could not find a way to define trigger with control characters, I resort to KeyDown event. However, I am not be able to show the member list.
In order to exclude coding mistakes, I defined a trigger with printable char, then copied the same code to the Trigger event handler. That works.
Debugging reveals that if memberlist is shown from KeyDown, e.Cancel = True in IntelliPromptMemberListClosing event. Maybe that caused the memberlist to close?
Steven

Comments (13)

Posted 20 years ago by Steven Liu
Avatar
I replaced CTRL-SPACE with CTRL-DOWN in KeyDown event, and that worked. My guess is that SPACE key canceled the memberlist, since it is one of the keys memberlist responds to.
Setting e.Handled = True in KeyDown event handler does not fix that.
Maybe SyntaxEditor should ignore key stroke if e.Handled = True?
Steven
Posted 20 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
I just looked at the code and it should not complete or abort the member list if you set Handled to true. There might be some other area that is causing it to close.

Have you tried making a custom Action for Ctrl+Space and adding it to the SyntaxEditor.KeyActionMappings?


Actipro Software Support

Posted 20 years ago by Steven Liu
Avatar
I cannot find the documentation and sample code for KeyActionMapping and how to associate it with EditAction. Would you point me to the right direction?

Here's a related issue: I want to insert "#ENDIF" if user types "#IF<RETURN>". I cannot use TRIGGER since it is a control character. I also found that RETURN key will not trigger KeyPress or KeyDown event. How can I do that? Should I use KeyActionMapping as well?

Steven
Posted 20 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Actions are easy to make. Just create a class that inherits EditAction and override the Execute method. Then create an instance of your class at runtime and add it to the KeyActionMappings collection on SyntaxEditor.

We're going to be reworking how keypresses occur in a future version so that we can allow easier control of things like this.


Actipro Software Support

Posted 20 years ago by Steven Liu
Avatar
Where do I put my custom EditAction? SyntaxEditor.KeyActionMappings.Add accepts a ActiproSoftware.WinUICore.KeyActionMapping object. How do I specify CTRL-SPACE?
Some kind of documentation would make it easier.
Steven
Posted 20 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
You do a line like this to create the KeyActionMapping and then add it to the collection.
new KeyActionMapping(Keys.Space, ModifierKeys.Ctrl, typeof(ShowMemberListAction))
We will try and add an easier way of adding ShowMemberList functionality in the future.

[ 06-23-2004: Message edited by: Actipro Software Support ]


Actipro Software Support

Posted 20 years ago by Steven Liu
Avatar
I put this code in Form.Load event:

Dim kam As New ActiproSoftware.WinUICore.KeyActionMapping(Keys.Space, ActiproSoftware.WinUICore.ModifierKeys.Ctrl, GetType(ListKeywordAction))
Me.editor.KeyActionMappings.Add(kam)
but VS wavelined "ActiproSoftware.WinUICore.ModifierKeys.Ctrl" and gave following message:
Value of type 'Integer' cannot be converted to 'ActiproSoftware.WinUICore.ModifierKeys'.

How come "ActiproSoftware.WinUICore.ModifierKeys.Ctrl" is not of type "ActiproSoftware.WinUICore.ModifierKeys"? I am confused, please help.

Steven Liu
Posted 20 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
That's odd. I wonder if it is because it was declared as an enum with a base type of uint. Try casting the value to "ActiproSoftware.WinUICore.ModifierKeys" and it should work.


Actipro Software Support

Posted 20 years ago by Steven Liu
Avatar
Type casting still gives the same error message.
Even simple statement like this gives error:

Dim k As ActiproSoftware.WinUICore.ModifierKeys = ActiproSoftware.WinUICore.ModifierKeys.Ctrl
I think you are right that UInt32 is the culprit. VB does not support UInt32 as an underlying type of enum. VB seems to give hints about this restriction:
1. when you type "Public Enum Test As ", the intellisense list only includes Byte/Integer/Long/Short.
2. if I define a variable as ActiproSoftware.WinUICore.ModifierKeys, during debug session, the infotip for that variable shows "unsupported type".

OK, this is a tricky one but I finally found a workaround:

Dim k As ActiproSoftware.WinUICore.ModifierKeys = [Enum].Parse(GetType(ActiproSoftware.WinUICore.ModifierKeys), "Ctrl", True)
i.e. parsing a string into ActiproSoftware.WinUICore.ModifierKeys works fine.

Still, I strongly recommend changing the underlying type to Int32.

Steven Liu
Posted 20 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Ok, we can change it for the future.


Actipro Software Support

Posted 20 years ago by Steven Liu
Avatar
Yes please, and Thank you.
It is causing a number of issues such as:
1. cannot use "=" operator on ActiproSoftware.WinUICore.ModifierKeys type, have to use equals method.
2. KeyActionMappings.GetApplicableMappings(Keys.Control Or Keys.A) return nothing. It returns SelectAllAction in C#, which is correct.
These issues can be work around but it saves a lot of time if fixed.

Steven Liu
Posted 20 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
It's changed for the next release.


Actipro Software Support

Posted 18 years ago by Dong JIA
Avatar
If you have some input methods, System will hook the "CTRL Space" first to switch input method. So it is a bad idea to deal with "CTRL Space". :)
The latest build of this product (v24.1.0) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.