[wxPython-users] Re: STC: events & deleting

Robin Dunn robin at alldunn.com
Fri Dec 7 16:06:33 PST 2007


Ivan Voras wrote:
> Robin Dunn wrote:
>> Ivan Voras wrote:
>>> Ivan Voras wrote:
>>>
>>>> ...but it doesn't work. It's like the mask is getting ignored: if I try
>>>> your lines (with the mistake of not including INSERTTEXT), it still
>>>> generates insert events AND it generates them from calling InsertText()
>>> It definitely looks like SetModEventMask doesn't work:
>>> modif: UserFlag B4-Insert  (1040), pos: 0, text: u'a\x00b', mask: 17
>>> modif: InsertText UserFlag  (17), pos: 0, text: u'abc', mask: 17
>>> modif: UserFlag B4-Delete  (2064), pos: 1, text: u'', mask: 17
>>> modif: DeleteText UserFlag  (18), pos: 1, text: u'b', mask: 17
>>>
>>> The only event I should have received is the second one, 
>> Where are you calling SetModEventMask from?  Perhaps the STC is already
>> in the process of calling the code that will send the event at the time
>> you try to set the mask.
> 
> I'm calling it from just after the stc object is created, but I tried
> moving it all around the code with no useful effects.

It obviously has an effect though, (setting it to zero results in no 
modify notifications at all) so perhaps there is just some 
misunderstanding of what the mask represents.


> 
>>> and that would
>>> also be wrong since it's generated by InsertText().
>> Scintilla doesn't differentiate between sending events only for user
>> actions and not programatic ones like wx usually does.  You'll need to
>> put a guard in your event handler if you don't want to respond to
>> programatic changes.
> 
> So what's the STC_PERFORM_USER flag for?

Ah, good catch.  I forgot that was in there.  That flag is set, along 
with one of the STC_MOD_ flags, if the operation was performed by the 
user.  So assuming that is accuate that should be how you can tell the 
difference.  See 
http://scintilla.sourceforge.net/ScintillaDoc.html#SCN_MODIFIED


-- 
Robin Dunn
Software Craftsman
http://wxPython.org  Java give you jitters?  Relax with wxPython!





More information about the wxpython-users mailing list