Re: Setting the Selected Segment of a Segmented Control

2014-10-15 Thread Daniel Blakemore
I can understand that it might behave that way.  It's not in and of itself
unreasonable, although in my opinion if the selected segment changes
visually, it's kind of weird not to send the message since the key isn't
UIControlEventValueChangedButReallyIOnlyCareAboutWhenTheChangeCameFromATouch.

The irksome thing is that it used to work and now doesn't and there's no
API diff around selectedSegment and the wording in the documentation didn't
change between iOS 7 and 8.

So I don't know if it's an intentional decision or an oversight.


--
Daniel Blakemore
Pixio Software

On Tue, Oct 14, 2014 at 9:20 PM, Richard Charles rcharles...@gmail.com
wrote:

 Not sure about iOS but on OS X programmatically calling

 [NSSegmentedControl setSelectedSegment:]

 does not trigger the target / action message.

 You need to programmatically respond after setting the selected segment.

 Richard Charles

 On Oct 14, 2014, at 6:55 PM, Daniel Blakemore dblakem...@pixio.com
 wrote:

  I have a simple problem.  I am programmatically setting the selected
  segment of a segmented control.  Then the segmented control is changing
  which segment appears selected on screen.
 
  You might be saying to yourself, this seems correct.  You would also be
  correct.
 
  What is incorrect is that while the control *appears* to have changed, my
  code knows nothing of this.
 
  I have an action added for the control event UIControlEventValueChanged
  which is called as expected when you tap the control.
 
  HOWEVER, when changing the control programmatically, no such event is
  generated.  This leaves my app in an inconsistent state.
 
  For reference, see this example project
  https://github.com/danblakemore/SegmentedNope.
 
  This worked in iOS 7.  It now does not.  What has changed?
 
  --
  Daniel Blakemore
  Pixio Software
  ___


___

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: Setting the Selected Segment of a Segmented Control

2014-10-15 Thread Keary Suska
On Oct 15, 2014, at 9:46 AM, Daniel Blakemore dblakem...@pixio.com wrote:

 I can understand that it might behave that way.  It's not in and of itself
 unreasonable, although in my opinion if the selected segment changes
 visually, it's kind of weird not to send the message since the key isn't
 UIControlEventValueChangedButReallyIOnlyCareAboutWhenTheChangeCameFromATouch.
 
 The irksome thing is that it used to work and now doesn't and there's no
 API diff around selectedSegment and the wording in the documentation didn't
 change between iOS 7 and 8.
 
 So I don't know if it's an intentional decision or an oversight.

The docs say,

UIControlEventValueChanged
A touch dragging or otherwise manipulating a control, causing it to emit a 
series of different values.

So, it seems documented to only trigger on a touch event, so it is possible 
that the behavior you had in iOS 7 was unintentional, since there is also no 
mention in release notes of change of behavior.

It is also useful to know that event handling almost exclusively relate to 
device input, not to programmatic changes. I.e., setting the value of a control 
is not an event so no event handling will get involved. You certainly could 
cause an event to programmatically fire…

So the main issue is that you are using an event handling method incorrectly to 
begin with...

 On Tue, Oct 14, 2014 at 9:20 PM, Richard Charles rcharles...@gmail.com
 wrote:
 
 Not sure about iOS but on OS X programmatically calling
 
[NSSegmentedControl setSelectedSegment:]
 
 does not trigger the target / action message.
 
 You need to programmatically respond after setting the selected segment.
 
 Richard Charles
 
 On Oct 14, 2014, at 6:55 PM, Daniel Blakemore dblakem...@pixio.com
 wrote:
 
 I have a simple problem.  I am programmatically setting the selected
 segment of a segmented control.  Then the segmented control is changing
 which segment appears selected on screen.
 
 You might be saying to yourself, this seems correct.  You would also be
 correct.
 
 What is incorrect is that while the control *appears* to have changed, my
 code knows nothing of this.
 
 I have an action added for the control event UIControlEventValueChanged
 which is called as expected when you tap the control.
 
 HOWEVER, when changing the control programmatically, no such event is
 generated.  This leaves my app in an inconsistent state.
 
 For reference, see this example project
 https://github.com/danblakemore/SegmentedNope.
 
 This worked in iOS 7.  It now does not.  What has changed?
 
 --
 Daniel Blakemore
 Pixio Software
 ___
 
 
 ___
 
 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/cocoa-dev%40esoteritech.com
 
 This email sent to cocoa-...@esoteritech.com

Keary Suska
Esoteritech, Inc.



___

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: Setting the Selected Segment of a Segmented Control

2014-10-15 Thread Scott Ribe
On Oct 15, 2014, at 10:00 AM, Keary Suska cocoa-...@esoteritech.com wrote:

 It is also useful to know that event handling almost exclusively relate to 
 device input, not to programmatic changes. I.e., setting the value of a 
 control is not an event so no event handling will get involved. You 
 certainly could cause an event to programmatically fire…

Also, in general, there's a good reason for this behavior. If events were to 
fire on programmatic changes, then you'd have ALL SORTS of infinite loops 
triggered when responding to input events, each one of which would require you 
to set some flag before changing a control's state, so that the event handler 
for that event would know *not* to propagate changes.

It would be an absolute nightmare to code to begin with, and even worse to 
maintain...

-- 
Scott Ribe
scott_r...@elevated-dev.com
http://www.elevated-dev.com/
(303) 722-0567 voice





___

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: Setting the Selected Segment of a Segmented Control

2014-10-15 Thread Daniel Blakemore
I wouldn't say that I was using it incorrectly since the user also can
change the segmented control, but when the form fails to validate, it
shifts to the unfinished section programmatically.

I wondered if someone would call me on the fact that they all fall under
the UIControlEvents which are all essentially touch related.  Whenever I
write custom controls, I elect to sent actions for the value changed
control event (where the control has a value, obviously) on programmatic
changes.  I understand that it might not be reasonable to expect that from
UIKit.  I've never had an issue with needing to be concerned about infinite
loops since the desired behavior was always to eliminate code duplication
by using the same function for both touch and programmatic changes..

There's not really an issue with just calling the function I registered,
but it feels wrong to call a method set up specifically to be called by the
system.  It triggers the same mental red flags as calling layoutSubviews
(rather than layoutIfNeeded) or something else that is reserved for the
system to call.

Thanks for the feedback.


--
Daniel Blakemore
Pixio Software

On Wed, Oct 15, 2014 at 10:12 AM, Scott Ribe scott_r...@elevated-dev.com
wrote:

 On Oct 15, 2014, at 10:00 AM, Keary Suska cocoa-...@esoteritech.com
 wrote:

  It is also useful to know that event handling almost exclusively
 relate to device input, not to programmatic changes. I.e., setting the
 value of a control is not an event so no event handling will get
 involved. You certainly could cause an event to programmatically fire…

 Also, in general, there's a good reason for this behavior. If events were
 to fire on programmatic changes, then you'd have ALL SORTS of infinite
 loops triggered when responding to input events, each one of which would
 require you to set some flag before changing a control's state, so that the
 event handler for that event would know *not* to propagate changes.

 It would be an absolute nightmare to code to begin with, and even worse to
 maintain...

 --
 Scott Ribe
 scott_r...@elevated-dev.com
 http://www.elevated-dev.com/
 (303) 722-0567 voice





___

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

Setting the Selected Segment of a Segmented Control

2014-10-14 Thread Daniel Blakemore
I have a simple problem.  I am programmatically setting the selected
segment of a segmented control.  Then the segmented control is changing
which segment appears selected on screen.

You might be saying to yourself, this seems correct.  You would also be
correct.

What is incorrect is that while the control *appears* to have changed, my
code knows nothing of this.

I have an action added for the control event UIControlEventValueChanged
which is called as expected when you tap the control.

HOWEVER, when changing the control programmatically, no such event is
generated.  This leaves my app in an inconsistent state.

For reference, see this example project
https://github.com/danblakemore/SegmentedNope.

This worked in iOS 7.  It now does not.  What has changed?

--
Daniel Blakemore
Pixio Software
___

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: Setting the Selected Segment of a Segmented Control

2014-10-14 Thread Richard Charles
Not sure about iOS but on OS X programmatically calling

[NSSegmentedControl setSelectedSegment:]

does not trigger the target / action message.

You need to programmatically respond after setting the selected segment.

Richard Charles

On Oct 14, 2014, at 6:55 PM, Daniel Blakemore dblakem...@pixio.com wrote:

 I have a simple problem.  I am programmatically setting the selected
 segment of a segmented control.  Then the segmented control is changing
 which segment appears selected on screen.
 
 You might be saying to yourself, this seems correct.  You would also be
 correct.
 
 What is incorrect is that while the control *appears* to have changed, my
 code knows nothing of this.
 
 I have an action added for the control event UIControlEventValueChanged
 which is called as expected when you tap the control.
 
 HOWEVER, when changing the control programmatically, no such event is
 generated.  This leaves my app in an inconsistent state.
 
 For reference, see this example project
 https://github.com/danblakemore/SegmentedNope.
 
 This worked in iOS 7.  It now does not.  What has changed?
 
 --
 Daniel Blakemore
 Pixio Software
 ___

___

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