We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

access to lexem stack in ContextChoiceBeforeOpen event handler

Thread ID:

Created:

Updated:

Platform:

Replies:

54110 Dec 30,2006 08:38 PM Jan 14,2007 09:49 AM Windows Forms 12
loading
Tags: EditControl
Administrator [Syncfusion]
Asked On December 30, 2006 08:38 PM

Hi,

I'm trying to get access to the lexem stack in the ContextChoiceBeforeOpen event handler in order to decide whether or not the context choice should be displayed. I thought that I'd be able to use the control's ContextChoiceController.Dropper.Config.ParentConfig
but it never seems to match up to the dropper's true parent (as confirmed by using the very helpful stack printing context tool tips from one of the samples).

Is ParentConfig not supported here? Any thoughts on how I can get access to the lexem stack?

thanks,
-travis

Administrator [Syncfusion]
Replied On January 3, 2007 02:53 PM

Hi Travis,

Our apologies for the delayed response. It is possible to use the ContextChoiceController.Dropper.Config.ParentConfig in the ContextChoiceBeforeOpen event. I
have attached a sample that illustrates this. Let me know if this meets your requirements.

Thanks for your patience.

Regards,
Ebenezer.P

sample

Administrator [Syncfusion]
Replied On January 3, 2007 07:06 PM

Thanks Ebenezer. I am doing what you did in your sample. It looks like the difference is in the way I've defined my lexem which I wish to drop a context choice.

Building upon your example, how would you get this lexem to work inside of String1?



I've used this lexem to syntax highlight TSQL like variables (e.g. @dayOfWeek). Now I'd like to get it to drop a context choice with the contents of the context choice to vary depending on the parent lexem. Unfortunately when I define the lexem as above, the parent config is not what I'd expect when the event is fired. It is correct after the user finishes typing though. Any suggestions?

thanks,
travis


>Hi Travis,

Our apologies for the delayed response. It is possible to use the ContextChoiceController.Dropper.Config.ParentConfig in the ContextChoiceBeforeOpen event. I
have attached a sample that illustrates this. Let me know if this meets your requirements.

Thanks for your patience.

Regards,
Ebenezer.P

sample

Administrator [Syncfusion]
Replied On January 3, 2007 07:34 PM

Looks like the lexem xml didn't make it into the forum.

It is attached.

lexem BeginBlock="@" EndBlock="\W+" IsEndRegex="true" Type="Variable" DropContextChoiceList="true"

variableLexem.zip

Administrator [Syncfusion]
Replied On January 4, 2007 07:24 AM

Hi Travis,

Our apologies for the delayed response. It is possible to get the lexem to work inside of String1 using ContinueBlock. I have attached a sample that illustrates this. Let me know if this meets your requirements.

Thanks for your patience.

Regards,
Ebenezer.P

sample

Administrator [Syncfusion]
Replied On January 4, 2007 09:19 PM

Thanks again Ebenezer. Getting closer but not exactly what I'm looking for.

This is what I'm after:

1) When a user presses the @ key, a context choice is dropped immediately and the parent config is accessible. In the sample you gave, the context choice only drops down after I press a non-word character.

2) The lexem for the @ style variables is also accessible outside of String1 sublexem and has similar context choice dropping behavior except the context choice is filled with different data. In the sample, @ didn't work outside of String1 (''). Again, as soon as @ is pressed, the context choice should be pressed.

Any suggestions?

thanks,
Travis

Administrator [Syncfusion]
Replied On January 6, 2007 07:09 PM

Hmm... the only time I can get access to the real parent config inside of ContextChoiceBeforeOpen is when the lexem is defined inside of another lexem that sets OnlyLocalSublexems="true". Unfortunately I can't use OnlyLocalSublexems here since any of the other lexems are valid.

Also, still wondering about how to get @ key to drop down a context choice immediately. I've tried this which is closer but it seems to crash the control when editing (has some line wrapping issues):

lexem BeginBlock="@" EndBlock="\w*" IsEndRegex="true" Type="Variable" DropContextChoiceList="true"


Administrator [Syncfusion]
Replied On January 6, 2007 07:30 PM

Sorry, the avove lexem should have been (note the EndBlock):

lexem BeginBlock="@" EndBlock=".*" IsEndRegex="true" Type="Variable" DropContextChoiceList="true"

using EndBlock="\w*" doesn't cause the crash/display issues but also doesn't drop down on the @ keypress.


Administrator [Syncfusion]
Replied On January 8, 2007 07:26 AM

Hi Travis,

Our apologies for the delayed response. It is possible to drop a context choice as soon as @ is pressed. It is also possible for @ to work outside of String1. I have attached a sample that illustrates this. Let me know if this meets your requirements.

Thanks for your patience.

Regards,
Ebenezer.P

sample

Administrator [Syncfusion]
Replied On January 13, 2007 05:17 PM

Hey Ebenezer,

Hmm. Still not what I'm after. The way you defined a variable:

lexem BeginBlock="@" Type="Variable" ropContextChoiceList="true"

only marks "@" as type Variable. It doesn't also mark the name that comes after the @ prefix as type variable.

I would like a string like "@hello" to be considered a lexem of type Variable. Additionally I'd like the context choice list to be able to drop on the initial key press of @. I can get "@hello" to be considered a lexem of type Variable. I just can't get the context choice to drop down on the first key press.

Is this possible?

-travis

Administrator [Syncfusion]
Replied On January 13, 2007 06:03 PM

Back to the issue of the stack... your example uses OnlyLocalSublexems="true" and this appears to work (the lexem parent matches with the actual text) in the ContextChoiceBeforeOpen handler. Can this be achieved with OnlyLocalSublexems="false"? When I do this I do not get the correct parent.

Administrator [Syncfusion]
Replied On January 14, 2007 09:39 AM

I've figured it out. To get the context choice to drop on initial @ keypress issue, I needed to create a complex lexem for the variable type. It now looks like this:

lexem BeginBlock="@" Type="Variable" DropContextChoiceList="true" OnlyLocalSublexems="true" IsComplex="true"
SubLexems
lexem BeginBlock="\w*" IsBeginRegex="true" Type="Variable"
SubLexems
lexem

This correctly classifies the entire variable name as type variable.

Administrator [Syncfusion]
Replied On January 14, 2007 09:49 AM

Also, to work around the parent config issue I ended up using the editor control's GetCurrentStack() method. This has the correct stack when called from the ContextChoiceBeforeOpen event handler. It also works for complex lexems that don't set OnlyLocalSublexems="true" (I could not get editor.ContextChoiceController.Dropper.Config.ParentConfig to work in that case).

-Travis

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;