Posted 19 years ago by painetraine
I was looking tonight for an event or some way to know when state changes occur. ie. when I go from DefaultState to CommentState or some other state change.

I looked for something like StateChange or some other event but couldn't find anything. Is there any way you could fire an event when the state changes and provide the old state and the new state in the event args?

Or, maybe I just overlooked it in the docs and you can point me to it.

My problem is that I have a statedefined like so:

<ExplicitPatternGroup Type="StartScope" Token="TodoCommentStartToken" Style="CommentDelimiterStyle" PatternValue="// TODO:" />

And I want to know as soon as the user enters the TodoCommentState by pressing the : but creating the following:

<KeyPressTrigger Key="TodoTrigger" Character=":">
<KeyPressTriggerValidState State="TodoCommentState" />

Doesn't work because when I press the : I haven't entered the TodoCommentState yet but I don't want the trigger to fire whenever I press : either. It would be helpful if there was some type of StateChanged event where I could see that the new state is now TodoCommentState.

Just to make your job harder, if it would be possible to know if the current state under the cursor changed because of deletion/insertion/typing/mousemove that would be helpful as well <IMG SRC="smile.gif" border="0">


Comments (2)

Posted 19 years ago by Boyd - Sr. Software Developer, Patterson Consulting, LLC
Without an event for this, couldn't you just use the SelectionChanged event to see what the state of the current selection is? If you store the value from the previous state, you could compare the two to determine if the state changed.

Just a suggestion... wrapping it up in an event would be nice too <IMG SRC="smile.gif" border="0">
Posted 19 years ago by Actipro Software Support - Cleveland, OH, USA
In your example, the : will always be in your default state since the trigger fires before the : character is inserted and parsed to enter the new TodoCommentState.

As Boyd said, checking in the SelectionChanged event for a state change is probably the best way to do what you want.

Would it be helpful if we added an enumeration of flags that would be set and provided in the SelectionChanged event args? We could also look into including the modification(s) that caused the event. The only major problem I can think of offhand is that sometimes multiple modifications are cached and cause a single selection changed event. What do you think the best way to provide all this sort of data would be considering the above problem?

[ 01-09-2005: Message edited by: Actipro Software Support ]

Actipro Software Support

The latest build of this product (v24.1.0) was released 4 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.