Author Topic: wxSmith: Slider event not fired  (Read 3898 times)

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9615
wxSmith: Slider event not fired
« on: January 07, 2009, 11:50:24 am »
Dear Byo,
I am using wxSmith to embed a slider in a configuration dialog.
I have attched to the EVT_COMMAND_SCROLL which creates this code:
Code
Connect(ID_SLD_MINUTES,wxEVT_SCROLL_TOP|wxEVT_SCROLL_BOTTOM|wxEVT_SCROLL_LINEUP|wxEVT_SCROLL_LINEDOWN|wxEVT_SCROLL_PAGEUP|wxEVT_SCROLL_PAGEDOWN|wxEVT_SCROLL_THUMBTRACK|wxEVT_SCROLL_THUMBRELEASE|wxEVT_SCROLL_CHANGED,(wxObjectEventFunction)&TimeDlg::OnMinutesChanged);
unfortunately the method is never called. If I add the "same" manually into the event table like:
Code
BEGIN_EVENT_TABLE(TimeDlg,wxDialog)
  EVT_COMMAND_SCROLL(ID_SLD_MINUTES, TimeDlg::OnMinutesChanged)
END_EVENT_TABLE()
...then it works.
Probably it_'s not a wxSmith issue... but just in case it is I'll report it here and do some further investigations...
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ

Offline jens

  • Administrator
  • Lives here!
  • *****
  • Posts: 7254
Re: wxSmith: Slider event not fired
« Reply #1 on: January 07, 2009, 09:47:22 pm »
The code created by wxSmith can not work, because wxEventType is internally an int ("typedef int wxEventType;") and newly created events are generated with the increment operator.

So putting multiple events together with "|" can never do what you expect.

The best way would be to use the event_table, otherwise all events have to be connected one by one (if "Connect()" shall be used all events have to be connected as if you chose them manually and connect them all with the same event handler).
« Last Edit: January 07, 2009, 10:45:59 pm by jens »

Offline byo

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 837
Re: wxSmith: Slider event not fired
« Reply #2 on: January 07, 2009, 11:51:06 pm »
Surely a bug - preprocessor expands the macro to or-ed version probably.
The only solution for now I could suggest is not to use the EVT_COMMAND_SCROLL but connect all other events separately to the same function.

Regards
   BYO

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9615
Re: wxSmith: Slider event not fired
« Reply #3 on: January 08, 2009, 08:52:28 am »
The only solution for now I could suggest is not to use the EVT_COMMAND_SCROLL but connect all other events separately to the same function.
...which is somehow the proposal of Jens... ;-) Thanks guys.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ