[share code] SliderWithLabel class for ui.Slider() featuring editable label
@cook , I will capitulate. But, I still believe in what I say. But it will not be proven with some test code. You need to implement it in a multi view app before you will start to see the limitations or restrictions. Sample code is just so different. You can make everything work in sample code somehow. But as you start to build a app, things change. Scope/reachablilty starts becoming big issues. I mean to not have to cludge connections between objects. Again this goes back to MCV (MODEL, CONTROLLER,VIEW) or close to that.
But I will stand corrected if need be
I say, try to match the interface if the thing you are replicating. ui.Slider has
actionso an action will be what someone expects.
There is also nothing wrong with using both a delegate and an action -- such as
ui.TextView, which have an action which is called for the most common delegate item, along with delegate items. Both can be set.
IMHO a delegate makes sense when there are more than one type of callback, or when a callback needs other info instead of just
sender. But for single action delegates, an action is easier to work with, since it requires less code, and is more easily discoverable (how many times have you had to pull up the docs to remember whether it is
@cook , ok. I am a little drunk now. But, on a single view, a action seems exactly the correct choice.
But I am just trying to differentiate between test code and actual implementation of a full application.
I have tried it many times, where objects are out of reach when you start to make a functional application.
I am not saying I am right. Because I have been proven wrong many times. Really, I am not trying to argue. I am just saying as you start to implement a application comprised of many views/subviews it gets a lot harder to keep in control of the scope of your objects in a meaningful way.
But I will stop now. As I say, is just my opinion. 😜🎉🎉🎉
@phuket2 I understand the point you are trying to make. My thoughts are just the same as @jonb has said. If I had a dollar for every time I pushed the 'copy' button on top of the tableview delegates code in the docs.... For now I'll just leave an action. I don't think there's a need for any other callbacks. If there was a delegate I think at most we have four options:
label_should_enter_value(return true or false)
slider_should_slide(return true or false)
But option three and four are also possible to implement just with some keyword args. Option one and two just seem the same overall. I think in the end you just get a bit of overkill implementing a delegate when most likely people just need to get the
sender.valuewhich is easier to implement with the
Anyway... I have some thoughts about MVC ... not specific to this but it got me thinking. When I have some time to write them down a bit I'll share with you.
@cook ,I understand. You of course should leave it as you feels it works. And that's why we edit: ask the more experienced guys in the first place. I think my own limitations/ability frustrates my at times. I do get backed it corners quite often and it frustrates the hell out of me. I can code my way out of the corner, but it seems so ugly to me and it's clear to me my design is just wrong.
When I was younger I had very little practice using OOP. And whilst I really love it in Python, I don't have the object design skills to pull it off. I think I can do simple things. It's just when the project starts to grow, I quickly see my design is does not support what I want to achieve in a elegant way. I this this is another problem for me, if it's not elegant I tend to sort of freeze up. Rather than just code though it and get something working.
Of course impatience is another factor. Trying to go to fast, not thinking things out.
I am thinking the smartest thing for me to do it to give up programming, lol no only joking 😬 I enjoy it to much, but I should take a huge step back and get my head MCV paradigm.
But to all, I make my comments in good faith. Even if they are incorrect, at the time of writing I believe in them. And I really appreciate all the help I receive from all of you in this forum. It's invaluable