Get wxEvtHandler from event???

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Mick P.
Earned some good credits
Earned some good credits
Posts: 110
Joined: Thu Jun 06, 2019 3:41 am
Contact:

Re: Get wxEvtHandler from event???

Post by Mick P. » Thu Sep 05, 2019 10:58 pm

ONEEYEMAN wrote:
Thu Sep 05, 2019 6:18 pm
Hi,
But what problem you are trying to solve?

And just to add to the discussion - not all events can be handled.
Or some events can have multiple event handlers.
Or some events can be handled both in parent and the child classes.

How do you handle all possible scenarios?

Thank you.
Well, wxWidgets does things unusually. You can say that an event is like this, but in other, better, systems there is a single event, and then that event is forwarded up the hierarchy, by way of new events. So I suppose, yes, the terminology can be construed more than one way. But what I meant, is with Bind and Connect, the context you set up for processing the event object, I call an event. That's the context I mean, clearly. Without wanting to play word games.

If events are not realized in the absence of a handler, then retrieving the handler (as if user data) is something that would be useful, and it's exactly what is done when you give it a "this" pointer in most instances, although that is technically separate, since it doesn't have to be the address of the event handler that is the object of the Bind or Connect call.

I don't know the details, so I ask. There's certainly no meaningful overhead in exposing that pointer. It would be a useful pointer to have in any event.

alys666
I live to help wx-kind
I live to help wx-kind
Posts: 192
Joined: Tue Oct 18, 2016 2:31 pm

Re: Get wxEvtHandler from event???

Post by alys666 » Fri Sep 06, 2019 12:10 am

Mick P. wrote:
Thu Sep 05, 2019 10:58 pm
Well, wxWidgets does things unusually. You can say that an event is like this, but in other, better, systems there is a single event, and then that event is forwarded up the hierarchy, by way of new events. So I suppose, yes, the terminology can be construed more than one way. But what I meant, is with Bind and Connect, the context you set up for processing the event object, I call an event. That's the context I mean, clearly. Without wanting to play word games.

If events are not realized in the absence of a handler, then retrieving the handler (as if user data) is something that would be useful, and it's exactly what is done when you give it a "this" pointer in most instances, although that is technically separate, since it doesn't have to be the address of the event handler that is the object of the Bind or Connect call.

I don't know the details, so I ask. There's certainly no meaningful overhead in exposing that pointer. It would be a useful pointer to have in any event.
wxWidgets does things with events absolutely cannonicaly, and any other idea is just wrong. Or it is not an "event handling", but something else. the same idea is in C#, Java, and everywhere.
idea of event handling is simple - separate and hide a logic of event occurence and of its handling. if timer raises 1 second event, he must not know who will consume it. timer says to event dispatcher - raise my <1 sec event>, and event dispatcher just calls all registered handlers and give them this event as parameter. there could be dozens, who want to consume this event and somehow react on it.

event cannot be associated with particular handler, because there could be no handler, or a lot of handlers.
in such systems events are broadcasting.

you use <this> to attach handler to event, just because you are attaching a method of a class, which must be called with instance pointer(<this>), formally you are delegating a method of some class.
to call usual function via pointer, you just need an address of this function.
but to call instance method via pointer, you need pointer to instance and way to retrieve actual address of method(because it can be virtual). this pair is so called <delegate>.
that's why you need to give <this>. just to give an ability to call method of a particular instance.
ubuntu 16.04, wxWidgets 3.0.4

User avatar
evstevemd
Part Of The Furniture
Part Of The Furniture
Posts: 2251
Joined: Wed Jan 28, 2009 11:57 am
Location: United Republic of Tanzania
Contact:

Re: Get wxEvtHandler from event???

Post by evstevemd » Fri Sep 06, 2019 7:15 am

Hi Mick,
may be explaining what you are trying to do will help get you solution. As of now am confused as to what exactly you are trying to do and where exactly you cannot make progress
Chief Justice: We have trouble dear citizens!
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
[Ubuntu 15.04/Windows 10 Pro - GCC/MinGW, CodeLite IDE et al]

Mick P.
Earned some good credits
Earned some good credits
Posts: 110
Joined: Thu Jun 06, 2019 3:41 am
Contact:

Re: Get wxEvtHandler from event???

Post by Mick P. » Fri Sep 06, 2019 12:08 pm

alys666 wrote:
Fri Sep 06, 2019 12:10 am
event cannot be associated with particular handler, because there could be no handler, or a lot of handlers.
in such systems events are broadcasting.
When you call Bind with a -> in C++ you are associating with a handler. The procedure fed to Bind is called in the context of the handler/functor.

I'm sorry you all are overthinking this. I can't help it. I've been programming with C++ for going on 20yrs. These things can't be explained more clearly than to literally teach C++ to laymen at the same time.

User avatar
doublemax
Moderator
Moderator
Posts: 13985
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Get wxEvtHandler from event???

Post by doublemax » Fri Sep 06, 2019 12:32 pm

I'm sorry you all are overthinking this. I can't help it. I've been programming with C++ for going on 20yrs. These things can't be explained more clearly than to literally teach C++ to laymen at the same time.
You really need to get off your high horse, thinking that you're the best programmer in the world and we're all idiots here.

Fact is that i usually don't bother to respond to your threads any more, because it's really hard to follow what you really want. And no, i don't think the problem lies on our side, it's on your side.

As for the current question: There are only two objects involved, the actual event handler that you can access with "this" inside the event handling method and the object that created the event which you can access with wxEvent::GetEventObject(). If these two are not sufficient, i don't know what else you're looking for.
Use the source, Luke!

Mick P.
Earned some good credits
Earned some good credits
Posts: 110
Joined: Thu Jun 06, 2019 3:41 am
Contact:

Re: Get wxEvtHandler from event???

Post by Mick P. » Sun Sep 08, 2019 1:25 am

doublemax wrote:
Fri Sep 06, 2019 12:32 pm
I'm sorry you all are overthinking this. I can't help it. I've been programming with C++ for going on 20yrs. These things can't be explained more clearly than to literally teach C++ to laymen at the same time.
You really need to get off your high horse, thinking that you're the best programmer in the world and we're all idiots here.

Fact is that i usually don't bother to respond to your threads any more, because it's really hard to follow what you really want. And no, i don't think the problem lies on our side, it's on your side.

As for the current question: There are only two objects involved, the actual event handler that you can access with "this" inside the event handling method and the object that created the event which you can access with wxEvent::GetEventObject(). If these two are not sufficient, i don't know what else you're looking for.
Some things are implicitly hard to follow. And, FWIW, I'm not on a high horse. Maybe that is projection on your part. If I can't rephrase something, I don't know what recourse I have but to say so. Sorry. (I also don't think anyone here is an idiot. As a moderator you should be better than to impugn others' character.)

User avatar
evstevemd
Part Of The Furniture
Part Of The Furniture
Posts: 2251
Joined: Wed Jan 28, 2009 11:57 am
Location: United Republic of Tanzania
Contact:

Re: Get wxEvtHandler from event???

Post by evstevemd » Tue Sep 10, 2019 7:08 am

Hi,
Mick P. wrote:
Sun Sep 08, 2019 1:25 am
I'm not on a high horse. Maybe that is projection on your part. If I can't rephrase something, .... As a moderator you should be better than to impugn others' character.)
In that case DM is not alone. I came to the same conclusion that you seem to be a bit proud. I think that comes from how you reply back, especially when you don't agree or don't think that things should be that way. I think you can use better and more polite way. That is how I see it!
Chief Justice: We have trouble dear citizens!
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
[Ubuntu 15.04/Windows 10 Pro - GCC/MinGW, CodeLite IDE et al]

Mick P.
Earned some good credits
Earned some good credits
Posts: 110
Joined: Thu Jun 06, 2019 3:41 am
Contact:

Re: Get wxEvtHandler from event???

Post by Mick P. » Fri Sep 13, 2019 7:40 pm

evstevemd wrote:
Tue Sep 10, 2019 7:08 am
Hi,
Mick P. wrote:
Sun Sep 08, 2019 1:25 am
I'm not on a high horse. Maybe that is projection on your part. If I can't rephrase something, .... As a moderator you should be better than to impugn others' character.)
In that case DM is not alone. I came to the same conclusion that you seem to be a bit proud. I think that comes from how you reply back, especially when you don't agree or don't think that things should be that way. I think you can use better and more polite way. That is how I see it!
Everyone is different. In my experience changing behavior is nearly impossible, but that might be a matter of differences too. I definitely do have some bones to pick with how wxWidgets is managed over on the tracker side, where bugs are blown off and the atmosphere is generally antisocial and inhospitable. But I think I'm on the right side there. If anything I'm a good person to a fault, and I don't do deference to authority when said authority is in the wrong. That pisses them off.

ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 3402
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Get wxEvtHandler from event???

Post by ONEEYEMAN » Fri Sep 13, 2019 8:25 pm

Hi,
As people tried to explain several times to you - this is a free software. Nobody is getting paid for working on.
So when Vadim is asking for a reproducer - its not because he likes to do so. Its because he don't have time to do it and you as a reporter should already have a code that can be used not just a reproduce the problem, but also make sure that it is fixed.

Also, please remember - he is the most knowledgeable one and most active one in wx community. He is the author of the Universal port and he contributed a huge amount of time to create all those samplpes you should be basing you work off.

Most of the time he can spot a problem just by looking at the diff you submitted (diff to the sample). Just because he knows wx code base.
But if he doesn't it will take him a significantly less amount of time to simply apply the patch to the sample, recompile, confirm the behavior and see how hard it will be to fix it.

Now as you can guess he spends a significant amount of time with wxWidgets because he and his company (TT-solutions) uses the library in 95% of the projects. And that's how he makes his living. Not by working in the corporate world like you do.

Also, as you probably guess - this forum is by wx users for wx users.
No wx core developers are coming here. Vadim, Paul, Stefan, Robin, Julian, another Stefan - they have IRC, ML, bug trackers to exchange the ideas on where to go and how to best implement something in wx.

Now - you come in here and you can't spend 5 minutes of your time preparing the reproducer of the bug you are reporting and want to get fixed. For me it means only one thing - you don't care whether the bug gets fixed or not. Because only you know how do you use the library. Only you know what type of hardware do you have (OpenGL). Only you know what OS and compilker do you use to build the library and application. Only you know how are you building the library - using configure, makefiles, cmake or something else. Only you know the scenario on how to reproduce the project. Other people can only guess.

I understand you want to make the library better. But when many people said - please create a patch to the sample to reproduce a problem and tell how to reproduce it (in the sample), don't you think they are asking it not just because they like to do so.

Thank you.

Post Reply