WxTextUrlEvent

From WxWiki

Jump to: navigation, search

This works only on Win32 wxTextCtrl with both wxTE_RICH and wxTE_AUTO_URL styles.

It seems that this class stores a wxMouseEvent, as well as the start and end position of the URL in the wxTextCtrl.

  • ''const wxMouseEvent& GetMouseEvent()'' returns the mouse event
  • ''long GetURLStart()'' returns the start position of the URL
  • ''long GetURLEndStart()'' returns the end position of the URL

class WXDLLEXPORT wxTextUrlEvent : public wxCommandEvent { public:

   wxTextUrlEvent(int id, const wxMouseEvent& evtMouse,
                  long start, long end)
       : wxCommandEvent(wxEVT_COMMAND_TEXT_URL, id)
       , m_evtMouse(evtMouse), m_start(start), m_end(end)
       { }
   // get the mouse event which happend over the URL
   const wxMouseEvent& GetMouseEvent() const { return m_evtMouse; }
   // get the start of the URL
   long GetURLStart() const { return m_start; }
   // get the end of the URL
   long GetURLEnd() const { return m_end; }

protected:

   // the corresponding mouse event
   wxMouseEvent m_evtMouse;
   // the start and end indices of the URL in the text control
   long m_start,
        m_end;

private:

   DECLARE_DYNAMIC_CLASS(wxTextUrlEvent)

public:

   // for wxWin RTTI only, don't use
   wxTextUrlEvent() : m_evtMouse(), m_start(0), m_end(0) { }

};

Personal tools