Quantcast
Channel: Visual Studio Integrate forum
Viewing all articles
Browse latest Browse all 4410

How to change/customize priority of “LayoutChange” and “KeyUp” events in c#

$
0
0

I am working on a VSIX Text Adornment project. Here I have LayoutChanged event and KeyUp event (from KeyProcessor). Now when I press any key (suppose Enter), both the events are eligible to be executed. Now the problem is, LayoutChanged event is executing first and it does not let KeyUp event be executed (But at the very first time I press any key, the KeyUp event is executed and then after the LayoutChanged event executed. But later, LayoutChanged is only executed).

I want KeyUp event to be always executed first. Then the rest events

Following is code for both the events and constructor:

TextAdornment1:

publicTextAdornment1(IWpfTextView tv,ITextDocumentFactoryService textDocumentFactoryService){this._textDocumentFactoryService = textDocumentFactoryService;if(tv ==null){thrownewArgumentNullException("view");}this.layer = tv.GetAdornmentLayer("TextAdornment1");this.view = tv;}

KeyUp event:

publicoverridevoidKeyUp(KeyEventArgs args){this.view.LayoutChanged+=OnLayoutChangedEvent;if(args.Key==Key.Enter){KeyEventProcessor.layouytChangeOccured =0;KeyEventProcessor.isEnterKeyUp =true;}else{KeyEventProcessor.layouytChangeOccured =0;KeyEventProcessor.isEnterKeyUp =false;KeyEventProcessor.layouytChangeOccured =0;}}

LayoutChanged event:

internal async voidOnLayoutChangedEvent(object sender,TextViewLayoutChangedEventArgs e){OnLayoutChanged2(e);}

Viewing all articles
Browse latest Browse all 4410

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>