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. Image for the cookie policy date

access to lexem stack in ContextChoiceBeforeOpen event handler

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

12 Replies

AD Administrator Syncfusion Team January 3, 2007 07:53 PM UTC

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


AD Administrator Syncfusion Team January 4, 2007 12:06 AM UTC

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


AD Administrator Syncfusion Team January 4, 2007 12:34 AM UTC

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


AD Administrator Syncfusion Team January 4, 2007 12:24 PM UTC

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


AD Administrator Syncfusion Team January 5, 2007 02:19 AM UTC

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


AD Administrator Syncfusion Team January 7, 2007 12:09 AM UTC

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"



AD Administrator Syncfusion Team January 7, 2007 12:30 AM UTC

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.



AD Administrator Syncfusion Team January 8, 2007 12:26 PM UTC

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


AD Administrator Syncfusion Team January 13, 2007 10:17 PM UTC

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


AD Administrator Syncfusion Team January 13, 2007 11:03 PM UTC

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.


AD Administrator Syncfusion Team January 14, 2007 02:39 PM UTC

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.


AD Administrator Syncfusion Team January 14, 2007 02:49 PM UTC

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

Loader.
Live Chat Icon For mobile
Up arrow icon