Re: Was: Re: NSStepper - useless?
> > >> I'm just saying the stepper itself should not have a value, it should send >> actions to a controller so it can manipulate a numeric value in a model >> object, or it should be able (using bindings) to increment/decrement a >> model's value. Using the UI as a model isn't what MVC is all about. > > > OK, so by that argument, no controls should have a value. Sliders should not > have a value. How then is that control going to draw itself? The position of > the slider is determined by its value relative to its min and max. If that > value can't be determined then the control will appear incorrectly, and > controls have no way to "ask" the data model for a value - it's up to the > relevant controller to push the value to the control. > > Since all controls work that way, why should NSStepper be an exception? > > In general I would agree that caching a value in more than one place is not > usually a good idea because of all the synchronisation issues that implies, > but for controls it's justified. In any case, correct use of controls, > whether through target/action or through bindings, takes care of the synch. > issue. If you are having trouble with that, you probably haven't got it set > up correctly. I use text field/stepper/slider combinations all over the place > and have never had to concern myself with synch. issues, even though all > three in a triple store the same value - get it right and really, it Just > Works. > > You might as well get used to it, that's how it is. > > --Graham > I would simply say that NSStepper only knows about its own state. It is quite inline with MVC. What the op is asking for is a more generic vertically oriented segmented button or a pair of NSButtons. That is super easy to implement. NSStepper is a precise type of form control for incrementing/decrementing a value. The value can be mapped to any sequential data. Dates and times are quite suited to it. Really anything that might have a reasonably narrow, precise granular increment. The only real question I see is whether the data incremented might also need a large scale ability to increment like a slider or nob or a combo box. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Was: Re: NSStepper - useless?
On Feb 26, 2012, at 4:44 PM, William Squires wrote: >>> Why didn't they just make the NSStepper a custom view that draws two >>> arrows, and has two sent actions that you can connect? Or even a variation >>> of NSMatrix with two button cells that look like arrows. That would avoid >>> the problem entirely, and be more intuitive to use. >> >> Not really. The control's intended use is to increment and decrement a >> value. That's what it does. If you're not using the stepper for manipulating >> a numeric value, you should probably be using a different control. > > I'm just saying the stepper itself should not have a value, it should send > actions to a controller so it can manipulate a numeric value in a model > object, or it should be able (using bindings) to increment/decrement a > model's value. Using the UI as a model isn't what MVC is all about. The stepper having a value doesn't break MVC any more than a text field having a string value, or a slider having a numeric value, does. And bindings require that the stepper have a value to begin with. All basic controls are architected the same way — they all maintain a value which they display and manipulate. When that value changes, they send an action. A stepper doesn't display it's value, but there's little or no benefit to architecting it totally differently. That would just be pushing more responsibility onto the controller which isn't necessary when the stepper can do it correctly for everyone to begin with. Whatever scenario you've cooked up where you need to know whether the value is being incremented or decremented (which you can still easily do) is not the norm. -- Seth Willits ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Was: Re: NSStepper - useless?
On 27/02/2012, at 11:44 AM, William Squires wrote: > I'm just saying the stepper itself should not have a value, it should send > actions to a controller so it can manipulate a numeric value in a model > object, or it should be able (using bindings) to increment/decrement a > model's value. Using the UI as a model isn't what MVC is all about. OK, so by that argument, no controls should have a value. Sliders should not have a value. How then is that control going to draw itself? The position of the slider is determined by its value relative to its min and max. If that value can't be determined then the control will appear incorrectly, and controls have no way to "ask" the data model for a value - it's up to the relevant controller to push the value to the control. Since all controls work that way, why should NSStepper be an exception? In general I would agree that caching a value in more than one place is not usually a good idea because of all the synchronisation issues that implies, but for controls it's justified. In any case, correct use of controls, whether through target/action or through bindings, takes care of the synch. issue. If you are having trouble with that, you probably haven't got it set up correctly. I use text field/stepper/slider combinations all over the place and have never had to concern myself with synch. issues, even though all three in a triple store the same value - get it right and really, it Just Works. You might as well get used to it, that's how it is. --Graham ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Was: Re: NSStepper - useless?
On Feb 23, 2012, at 2:13 PM, Seth Willits wrote: > On Feb 23, 2012, at 6:16 AM, William Squires wrote: > >> From what I've read, the NSStepper has a bug (though practically, you'll >> never see it); if one were to click the up or down arrow on the control 2^32 >> times (assuming it's value is a 4-byte signed int,and is initialized to 0), >> it would wrap around (or raise an exception for integer overflow). Probably >> not what the user had in mind! > > It's pretty irrelevant, because you wouldn't be using a stepper control for > values in the billions. That'd be a poor UI. Just like if a table view had a > couple billion rows in it in (in 32-bit) it would have broken as well. But > it's a terrible thing to do in the first place. ;) > > >> Why didn't they just make the NSStepper a custom view that draws two arrows, >> and has two sent actions that you can connect? Or even a variation of >> NSMatrix with two button cells that look like arrows. That would avoid the >> problem entirely, and be more intuitive to use. > > Not really. The control's intended use is to increment and decrement a value. > That's what it does. If you're not using the stepper for manipulating a > numeric value, you should probably be using a different control. > I'm just saying the stepper itself should not have a value, it should send actions to a controller so it can manipulate a numeric value in a model object, or it should be able (using bindings) to increment/decrement a model's value. Using the UI as a model isn't what MVC is all about. > > -- > Seth Willits > > > ___ > > Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) > > Please do not post admin requests or moderator comments to the list. > Contact the moderators at cocoa-dev-admins(at)lists.apple.com > > Help/Unsubscribe/Update your Subscription: > https://lists.apple.com/mailman/options/cocoa-dev/wsquires%40satx.rr.com > > This email sent to wsqui...@satx.rr.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Was: Re: NSStepper - useless?
William Squires wrote: > Why didn't they just make the NSStepper a custom view that draws two arrows, > and has two sent actions that you can connect? Or even a variation of > NSMatrix with two button cells that look like arrows. That would avoid the > problem entirely, and be more intuitive to use. Um. Because that's not what the control *is*. An NSStepper is a numeric input, for which the interface happens to be a pair of arrows. It's not just a pair of arrows that do whatever you want in response to pressing on each of them. Think of "stepper" in the context of "motor." If it was just two arrows with connectable actions it would be less intuitive and more difficult to use for what it was designed to do. If you want to augment the intended behavior, KVO is probably the way to go. If you want to do something completely different, your should have your own control and it shouldn't look especially like a stepper. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Was: Re: NSStepper - useless?
On Feb 23, 2012, at 10:05 AM, Kyle Sluder wrote: > On Thu, Feb 23, 2012 at 6:16 AM, William Squires wrote: >> From what I've read, the NSStepper has a bug (though practically, you'll >> never see it); if one were to click the up or down arrow on the control 2^32 >> times (assuming it's value is a 4-byte signed int,and is initialized to 0), >> it would wrap around (or raise an exception for integer overflow). Probably >> not what the user had in mind! Why didn't they just make the NSStepper a >> custom view that draws two arrows, and has two sent actions that you can >> connect? Or even a variation of NSMatrix with two button cells that look >> like arrows. That would avoid the problem entirely, and be more intuitive to >> use. > > Because NSStepper is over 20 years old, dating back to when the way to > push values around was to wire up a control's action to another > control's -takeValueFrom: method. Besides, all sorts of crazy things > tend to happen anyway when you try to use UINT_MAX for anything > useful. Not to mention that this is really a programmer error. If you don't wan the value to overflow, set a sensible maximum. A similar issue could happen from any user-entry field. It's the developer's responsibility (IMHO) to set data entry constraints. Best, Keary Suska Esoteritech, Inc. "Demystifying technology for your home or business" ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Was: Re: NSStepper - useless?
On Feb 23, 2012, at 6:16 AM, William Squires wrote: > From what I've read, the NSStepper has a bug (though practically, you'll > never see it); if one were to click the up or down arrow on the control 2^32 > times (assuming it's value is a 4-byte signed int,and is initialized to 0), > it would wrap around (or raise an exception for integer overflow). Probably > not what the user had in mind! It's pretty irrelevant, because you wouldn't be using a stepper control for values in the billions. That'd be a poor UI. Just like if a table view had a couple billion rows in it in (in 32-bit) it would have broken as well. But it's a terrible thing to do in the first place. ;) > Why didn't they just make the NSStepper a custom view that draws two arrows, > and has two sent actions that you can connect? Or even a variation of > NSMatrix with two button cells that look like arrows. That would avoid the > problem entirely, and be more intuitive to use. Not really. The control's intended use is to increment and decrement a value. That's what it does. If you're not using the stepper for manipulating a numeric value, you should probably be using a different control. -- Seth Willits ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Was: Re: NSStepper - useless?
On Thu, Feb 23, 2012 at 6:16 AM, William Squires wrote: > From what I've read, the NSStepper has a bug (though practically, you'll > never see it); if one were to click the up or down arrow on the control 2^32 > times (assuming it's value is a 4-byte signed int,and is initialized to 0), > it would wrap around (or raise an exception for integer overflow). Probably > not what the user had in mind! Why didn't they just make the NSStepper a > custom view that draws two arrows, and has two sent actions that you can > connect? Or even a variation of NSMatrix with two button cells that look like > arrows. That would avoid the problem entirely, and be more intuitive to use. Because NSStepper is over 20 years old, dating back to when the way to push values around was to wire up a control's action to another control's -takeValueFrom: method. Besides, all sorts of crazy things tend to happen anyway when you try to use UINT_MAX for anything useful. --Kyle Sluder ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Was: Re: NSStepper - useless?
>From what I've read, the NSStepper has a bug (though practically, you'll never >see it); if one were to click the up or down arrow on the control 2^32 times >(assuming it's value is a 4-byte signed int,and is initialized to 0), it would >wrap around (or raise an exception for integer overflow). Probably not what >the user had in mind! Why didn't they just make the NSStepper a custom view >that draws two arrows, and has two sent actions that you can connect? Or even >a variation of NSMatrix with two button cells that look like arrows. That >would avoid the problem entirely, and be more intuitive to use. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSStepper - useless?
On Feb 22, 2012, at 09:11 PM, Seth Willits wrote: > On Feb 19, 2012, at 4:11 PM, William Squires wrote: > >> Okay, 'nuther dumb question. How do I hook the different arrows in an >> NSStepper to actions in my view controller? Or how do I ask (id)sender which >> arrow was clicked? > > You don't. You ask for the stepper's value. The best usage I've found is to have a property in your controller and bind the value of the stepper (and perhaps the associated text box) to the property. You could also then observe changes to the property with KVO, if you so desire. Martin > > > -- > Seth Willits > > ___ > > Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) > > Please do not post admin requests or moderator comments to the list. > Contact the moderators at cocoa-dev-admins(at)lists.apple.com > > Help/Unsubscribe/Update your Subscription: > https://lists.apple.com/mailman/options/cocoa-dev/martin.hewitson%40aei.mpg.de > > This email sent to martin.hewit...@aei.mpg.de Martin Hewitson Albert-Einstein-Institut Max-Planck-Institut fuer Gravitationsphysik und Universitaet Hannover Callinstr. 38, 30167 Hannover, Germany Tel: +49-511-762-17121, Fax: +49-511-762-5861 E-Mail: martin.hewit...@aei.mpg.de WWW: http://www.aei.mpg.de/~hewitson ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSStepper - useless?
On Feb 19, 2012, at 6:11 PM, William Squires wrote: > Okay, 'nuther dumb question. How do I hook the different arrows in an > NSStepper to actions in my view controller? Or how do I ask (id)sender which > arrow was clicked? > Remember that classes tend to inherit from superclasses. Not checking superclasses will get you every time with AppKit. Try AppKiDo for a great tool that makes it really really easy to see all of the documented methods a class responds to at once, including its inherited methods. In this case NSControl has your answer. If what you are really after is a vertical segmented button, you can create that easily. In this case, you will get a zero or a 1. A simple conditional statement will get you where you probably want to go with this. On a side note, please consider your post titles more thoughtfully. 2 reasons: 1) Many users search the archives, often via google. 2) Thoughtless titles like "it doesn't work" often get ignored by some of the most insightful and active people on the mailing list. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSStepper - useless?
On Feb 19, 2012, at 4:11 PM, William Squires wrote: > Okay, 'nuther dumb question. How do I hook the different arrows in an > NSStepper to actions in my view controller? Or how do I ask (id)sender which > arrow was clicked? NSStepper is intended to keep track of the value for you, so when the user clicks an arrow the stepper updates its value and notifies the target, which can then look at the control’s value. If you just need a pair of little arrows that will do something else than increment a number, you’re probably better off making two little NSButtons. —Jens smime.p7s Description: S/MIME cryptographic signature ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSStepper - useless?
On Feb 19, 2012, at 5:11 PM, William Squires wrote: > Okay, 'nuther dumb question. How do I hook the different arrows in an > NSStepper to actions in my view controller? Or how do I ask (id)sender which > arrow was clicked? You can't, at least not specifically, on both counts. All the stepper does is increment or decrement a numeric value. That's it. If you keep track of the last value set, you can determine whether the value went up or down, which would indicate which button was pressed. HTH, Keary Suska Esoteritech, Inc. "Demystifying technology for your home or business" ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSStepper - useless?
On 20/02/2012, at 11:11 AM, William Squires wrote: > Okay, 'nuther dumb question. How do I hook the different arrows in an > NSStepper to actions in my view controller? Or how do I ask (id)sender which > arrow was clicked? You can't, it works differently. Instead it has a "value" , just like a slider. This can be incremented or decremented, and the action method can extract the value and respond accordingly. In other words it tracks the value for you, you don't use it to increment or decrement a value in your data model. It's actually quite nice that it works this way, because you can hook it up with a textfield to the same action method, and set the two together, or bind them in pairs if you're using bindings. The max, min and increment amount can all be set in IB. --Graham ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSStepper - useless?
On 19 Feb 2012, at 6:11 PM, William Squires wrote: > Okay, 'nuther dumb question. How do I hook the different arrows in an > NSStepper to actions in my view controller? Or how do I ask (id)sender which > arrow was clicked? It's not useless, it just doesn't have the use you hope for. NSStepper is one control, with one value, and one action, not two buttons. Its function is to adjust its value in response to clicks. Clicking an arrow changes the value, and the action method informs you that the value has changed. Because your application is well-designed, you have a model object that holds the current value, and you can compare it to the new one. The difference informs you whether it went up or down. — F ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSStepper - useless?
On Feb 19, 2012, at 4:11 PM, William Squires wrote: > Okay, 'nuther dumb question. How do I hook the different arrows in an > NSStepper to actions in my view controller? Or how do I ask (id)sender which > arrow was clicked? You don't. You ask for the stepper's value. -- Seth Willits ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
NSStepper - useless?
Okay, 'nuther dumb question. How do I hook the different arrows in an NSStepper to actions in my view controller? Or how do I ask (id)sender which arrow was clicked? ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com