Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Visual Studio.NET / Extensibility / March 2005

Tip: Looking for answers? Try searching our database.

vsip core editor keypress

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Maxime LABELLE - 22 Mar 2005 17:29 GMT
Dear all,

I'm quite new to VSIP and am in the process of writing a syntax highlighter
for an old proprietary language that we are using internally.

I have therefore developped and successfully run a very simple VsPackage
with a VsEditorFactory that instantiates the core editor.

However, it appears that most keypresses are not handled by the editor. I
can only type characters, digits and probably the Del key but the Enter,
Backspace and Arrow keys are not handled. Others are probably not handled
either.

Is there something to pay attention to when instantiating the core editor?
My VsEditorFactory instantiates both a VsTextBuffer and a VsCodeWindow
object, sites the text buffer, hooks up the code window to the text buffer
and returns the appropriate interfaces.

However, it does *not* create a VsCodeWindowManager (yet) nor does it set
the resulting caption string and command guid.

I noticed that the last parameter of the
IVsEditorFactory::CreateEditorInstance() in the samples is a pointer to a
VSEDITORCREATEDOCWIN whereas it is documented in the VSIP EnvSDK as a pointer
to a BOOL...

Thanks for your help.
Cheers.
"Ed Dore [MSFT]" - 22 Mar 2005 22:09 GMT
Hi Maxime,

It sounds like accelerator keyboard messages aren't being processed
properly. Are you by chance parenting this code window in another window
(that implements IVsWindowPane)?

I did this some time ago with a C# package, where I created a VsCodeWindow
and parented it to a .net user control, and ran into a similar behavior.
The problem was that my user control (which derived from IVsWindowPane),
didn't call the code window's IVsWindowPane::TranslateAccelerator(). Once I
defered the TranslateAccelerator call to the core editor's IVsWindowPane,
the various keyboard messages worked fine.

Just a guess.

Sincerely,
Ed Dore [MSFT]

This post is 'AS IS' with no warranties, and confers no rights.
Fred Heida - 23 Mar 2005 21:26 GMT
Hi Ed,

Are there any samples available for doing this ? em.go hosting a
VsCodeWindow inside a
.net control ?

Cheers,
Fred

> Hi Maxime,
>
[quoted text clipped - 16 lines]
>
> This post is 'AS IS' with no warranties, and confers no rights.
"Ed Dore [MSFT]" - 24 Mar 2005 23:50 GMT
Hi Fred,

I have a sample that compiles against Whidbey Beta1 that does this. It's
basically a "proof of concept" package for some other stuff I was working
on for another customer. But I'd be more than happy to send you a copy.
Just email me (minus the ".online" portion in my email address), and I'll
send you a copy. I'm working on a new Beta2 variant that will implement
multiple views, one of which will host the codewindow as a child control on
a .net user control.

Basically, you have to revert to the Win32 API's to parent the codewindow's
HWND onto a usercontrol. It's kludgy, but it's the same technique we use
with our managed packages too.  

Sincerely,
Ed Dore [MSFT]

This post is 'AS IS' with no warranties, and confers no rights.
Maxime LABELLE - 23 Mar 2005 09:21 GMT
Well,

I have made some tests with the Figures sample collection and have found
that the FigEdt sample alone suffers from the exact same problem. It starts
to work correctly when the FigLgSvc sample is registered.

As it turns out, it seems I can have a language service without an editor
but I cannot have an editor without a language service. Is that correct?

Also, can both the language service and the editor be implemented in the
same VsPackage?

Cheers.
Maxime.
Gaston Milano - 23 Mar 2005 22:18 GMT
You have to inherit the keybindings from the TextEditor, you should write something like this:

Guid guid = NativeMethods.GUID_TextEditorFactory;
windowFrame.SetGuidProperty((int) __VSFPROPID.VSFPROPID_InheritKeyBindings, ref guid);

Regards,
Gaston

> Dear all,
>
[quoted text clipped - 24 lines]
> Thanks for your help.
> Cheers.
Maxime LABELLE - 24 Mar 2005 10:13 GMT
OK,

That puts me on the right track. However, it seems I have to do that from
the code window manager in a language service VsPackage. It seems to confirm
that you can have a language service VsPackage without an editor VsPackage
but not the other way around.

It sorts of make sense : in order to create a custom syntax highlighter, it
does not seem necessary to create a custom editor.

Thanks a lot.

> You have to inherit the keybindings from the TextEditor, you should write something like this:
>
[quoted text clipped - 3 lines]
> Regards,
> Gaston
"Ed Dore [MSFT]" - 24 Mar 2005 23:43 GMT
I've actually written both an editor without a language service, and a
language service without an editor.

You can set the VSFPROPID_InheritKeyBindings property from your editor
factory's CreateEditorInstance implementation as Gaston mentioned, or
alternatively return that same guid,  for that out pguidCmdUI argument.
Gaston's suggestion is the proper way to go though, as you may have
specific key bindings tied to your own package commands.

Sincerely,
Ed Dore [MSFT]

This post is 'AS IS' with no warranties, and confers no rights.
Maxime LABELLE - 25 Mar 2005 17:37 GMT
OK. I'm starting to understand.

Thanks for the clarifications.
Maxime.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.