Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] OnClick() event for base_control? #136

Open
khaf opened this issue Feb 5, 2020 · 3 comments
Open

[Question] OnClick() event for base_control? #136

khaf opened this issue Feb 5, 2020 · 3 comments

Comments

@khaf
Copy link

khaf commented Feb 5, 2020

Hi Vladimir, thanks for this library! It really has the TVision vibe.

I'm trying it to see if it will work for one of my projects, so I'll be filing issues as I encounter them, hope you find them useful. this is the first one:

Is there a reason OnClick() is not implemented for BaseControl?

@VladimirMarkelov
Copy link
Owner

Hi Khosrow,

You are welcome :)

I do not remember why I decided to do it. A few possible reasons:

First, I might be bitten by Go "inheritance" - I tried to implemented another "generic" method and then I got a bunch of strange errors. Only after I understood that Go inheritance != C++ inheritance, I was able to fix the trouble by removing "generic" code. So I chose a way to add OnClick on top level for controls that needs it.

Second reason: I made a library for my needs and OnClick() looked useless for some controls (e.g, for CheckBox it is not as useful as OnChange as it does not pass the current value of checkbox). For my home projects OnClick for Button was enough.

Third possible reason: my Delphi experience. In Delphi VCL OnClick was not common event, so I am not used to it.

@khaf
Copy link
Author

khaf commented Feb 6, 2020

Ah, a fellow Delphi veteran! I see why we seek the same thing.

Go doesn't have inheritance, only composition. Everyone gets it wrong in the first go :)

I take it you don't object to me to do a bit of surgery to fix it?

@VladimirMarkelov
Copy link
Owner

That was why I wrote inheritance quoted :) - people who came from Delphi/C++ it is not obvious and takes time to grasp the Go way.

While "surgery" does not break what works - I am fine with this 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants