Thread: wxWidgets and capturing EN_SELCHANGE

  1. #1
    The larch
    Join Date
    May 2006
    Posts
    3,573

    wxWidgets and capturing EN_SELCHANGE

    I'm writing a kind of Word-pad clone and what I want to do is to update the font and font-style selectors as the textattributes under the cursor position change (e.g you click in the middle of a paragraph with Courier New 12, and the respective comboboxes are updated with the new font data).

    It seems to me that the most appropriate way might be to respond to EN_SELCHANGE notification and check if the text-attributes have changed.

    However, the problem is how would I respond to this notification if wxWidgets doesn't seem to detect this event? Is there any way to tell the wxWidgets event handling mechanism that I'm interested in this notification? Or is there a way to have a callback function called when this notification occurs (something to do with hooks to monitor the messages send by the text editor)?
    I might be wrong.

    Thank you, anon. You sure know how to recognize different types of trees from quite a long way away.
    Quoted more than 1000 times (I hope).

  2. #2
    The larch
    Join Date
    May 2006
    Posts
    3,573
    I discovered that the text control example of wxWidgets features a rich text editor which can do that. It turned out this can be checked quite successfully each time when the control becomes idle (wxIdleEvent).

    Edit: This still doesn't work right. It causes flickering when a range is selected and makes it impossible to select a range by dragging mouse over it right-to-left (the wxWidgets example has the same problem). So it looks like a different solution is still needed.

    Edit 2: The cause of these anomalies appeared to be caused by wxTextCtrl::GetStyle which apparently removes selection? Works perfectly again when font data is retrieved with EM_GETCHARFORMAT. (Also wxTextCtrl::GetDefaultStyle appears to give good results.)
    Last edited by anon; 03-08-2009 at 10:12 AM.
    I might be wrong.

    Thank you, anon. You sure know how to recognize different types of trees from quite a long way away.
    Quoted more than 1000 times (I hope).

Popular pages Recent additions subscribe to a feed