<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Throttling NSSlider</title>
	<atom:link href="http://www.red-sweater.com/blog/64/throttling-nsslider/feed" rel="self" type="application/rss+xml" />
	<link>http://www.red-sweater.com/blog/64/throttling-nsslider</link>
	<description>Mac &#38; Technology Writings by Daniel Jalkut</description>
	<lastBuildDate>Wed, 18 Jan 2012 18:10:04 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.1</generator>
	<item>
		<title>By: Daniel Jalkut</title>
		<link>http://www.red-sweater.com/blog/64/throttling-nsslider/comment-page-1#comment-358</link>
		<dc:creator>Daniel Jalkut</dc:creator>
		<pubDate>Thu, 15 Dec 2005 01:20:19 +0000</pubDate>
		<guid isPermaLink="false">http://www.red-sweater.com/blog/?p=64#comment-358</guid>
		<description>Steven - good point. I tested this and discovered that there is in fact a weakness. If I move a slider knob away from and back to a certain position with a quick &quot;left-right&quot; of the arrow keys, I miss the &quot;moved back&quot; value.

Unfortunately, the slider&#039;s action message gets sent only on &quot;NSKeyDown&quot;. I don&#039;t see NSKeyUp events coming through the send method.

Perhaps the best solution &lt;em&gt;would&lt;/em&gt; be to simply install an NSTimer that &quot;resends&quot; the value after some timeout. Ugh. It&#039;s getting complicated.  I suppose if the slider remembers the last value it sent, and instead of storing an NSDate stores an NSTimer for the delay period, it can simply take over and enforce periodic sending. The logic for the send method could be:

1. If the NSTimer is non-nil, just ignore the send method, wait for the timer.
2. If the NSTimer is nil, carry out the send if different from last sent and install a timer for the delay duration.
3. When the timer expires, release the timer and carry out the send if the value is different from last sent.

This should guarantee that the slider always sends the last value, but never does so redundantly. Anybody spot a problem?</description>
		<content:encoded><![CDATA[<p>Steven &#8211; good point. I tested this and discovered that there is in fact a weakness. If I move a slider knob away from and back to a certain position with a quick &#8220;left-right&#8221; of the arrow keys, I miss the &#8220;moved back&#8221; value.</p>
<p>Unfortunately, the slider&#8217;s action message gets sent only on &#8220;NSKeyDown&#8221;. I don&#8217;t see NSKeyUp events coming through the send method.</p>
<p>Perhaps the best solution <em>would</em> be to simply install an NSTimer that &#8220;resends&#8221; the value after some timeout. Ugh. It&#8217;s getting complicated.  I suppose if the slider remembers the last value it sent, and instead of storing an NSDate stores an NSTimer for the delay period, it can simply take over and enforce periodic sending. The logic for the send method could be:</p>
<p>1. If the NSTimer is non-nil, just ignore the send method, wait for the timer.<br />
2. If the NSTimer is nil, carry out the send if different from last sent and install a timer for the delay duration.<br />
3. When the timer expires, release the timer and carry out the send if the value is different from last sent.</p>
<p>This should guarantee that the slider always sends the last value, but never does so redundantly. Anybody spot a problem?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Steven</title>
		<link>http://www.red-sweater.com/blog/64/throttling-nsslider/comment-page-1#comment-356</link>
		<dc:creator>Steven</dc:creator>
		<pubDate>Wed, 14 Dec 2005 15:01:14 +0000</pubDate>
		<guid isPermaLink="false">http://www.red-sweater.com/blog/?p=64#comment-356</guid>
		<description>If Full keyboard access is turned on in the Keyboard &amp; Mouse pane of System Preferences, sliders can be manipulated with the arrow keys, so you might want to be checking for other NSEvents. I don&#039;t have Xcode open but from just playing with slider controls, they seem to fire on NSKeyDown.</description>
		<content:encoded><![CDATA[<p>If Full keyboard access is turned on in the Keyboard &amp; Mouse pane of System Preferences, sliders can be manipulated with the arrow keys, so you might want to be checking for other NSEvents. I don&#8217;t have Xcode open but from just playing with slider controls, they seem to fire on NSKeyDown.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Daniel Jalkut</title>
		<link>http://www.red-sweater.com/blog/64/throttling-nsslider/comment-page-1#comment-352</link>
		<dc:creator>Daniel Jalkut</dc:creator>
		<pubDate>Sun, 11 Dec 2005 20:10:36 +0000</pubDate>
		<guid isPermaLink="false">http://www.red-sweater.com/blog/?p=64#comment-352</guid>
		<description>Jack - that&#039;s a great idea, thanks for posting!

OOP_Hater: I suggest you take your question to a mailing list like Cocoa-Dev on the Apple mailing lists.</description>
		<content:encoded><![CDATA[<p>Jack &#8211; that&#8217;s a great idea, thanks for posting!</p>
<p>OOP_Hater: I suggest you take your question to a mailing list like Cocoa-Dev on the Apple mailing lists.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: OOP_Hater</title>
		<link>http://www.red-sweater.com/blog/64/throttling-nsslider/comment-page-1#comment-351</link>
		<dc:creator>OOP_Hater</dc:creator>
		<pubDate>Sun, 11 Dec 2005 07:58:34 +0000</pubDate>
		<guid isPermaLink="false">http://www.red-sweater.com/blog/?p=64#comment-351</guid>
		<description>I just need a simple thing. My program uses a slider. How do I get the float values from the slider into the main part of the program? This should be easy, but I can&#039;t get it to work. I&#039;ve done the subclass, the instance, the add files. I&#039;m sure the slider value is making it into the slider.m file. But I can&#039;t get it from there to the main part of the program. When I try I get the error mesage that&#039;s it&#039;s an undeclared value.

Excpet that it IS DECLARED!!!

Object oriented programming sucks!!!!!!!!!!</description>
		<content:encoded><![CDATA[<p>I just need a simple thing. My program uses a slider. How do I get the float values from the slider into the main part of the program? This should be easy, but I can&#8217;t get it to work. I&#8217;ve done the subclass, the instance, the add files. I&#8217;m sure the slider value is making it into the slider.m file. But I can&#8217;t get it from there to the main part of the program. When I try I get the error mesage that&#8217;s it&#8217;s an undeclared value.</p>
<p>Excpet that it IS DECLARED!!!</p>
<p>Object oriented programming sucks!!!!!!!!!!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jack Nutting</title>
		<link>http://www.red-sweater.com/blog/64/throttling-nsslider/comment-page-1#comment-347</link>
		<dc:creator>Jack Nutting</dc:creator>
		<pubDate>Sat, 10 Dec 2005 10:09:54 +0000</pubDate>
		<guid isPermaLink="false">http://www.red-sweater.com/blog/?p=64#comment-347</guid>
		<description>Within sendAction:to:, or within the target action itself, you can check the value of [[NSApp currentEvent] type].  If it&#039;s NSLeftMouseUp, you&#039;ve got the final state of of the slider cell.  I&#039;ve used this to make one sort of quick GUI updating occur while the slider is moving, and another, slower action to occur when the user releases the mouse button.</description>
		<content:encoded><![CDATA[<p>Within sendAction:to:, or within the target action itself, you can check the value of [[NSApp currentEvent] type].  If it&#8217;s NSLeftMouseUp, you&#8217;ve got the final state of of the slider cell.  I&#8217;ve used this to make one sort of quick GUI updating occur while the slider is moving, and another, slower action to occur when the user releases the mouse button.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Daniel Jalkut</title>
		<link>http://www.red-sweater.com/blog/64/throttling-nsslider/comment-page-1#comment-344</link>
		<dc:creator>Daniel Jalkut</dc:creator>
		<pubDate>Thu, 08 Dec 2005 16:06:26 +0000</pubDate>
		<guid isPermaLink="false">http://www.red-sweater.com/blog/?p=64#comment-344</guid>
		<description>Good point, Jon. I thought about this briefly but decided that the frequency of my throttle was still so fast that it was unlikely to &quot;miss&quot; a final event. I agree it&#039;s possible though, and probably demands a more robust solution.

One possibility would be to subclass NSSliderCell and, in its &quot;stopTracking...&quot; method, send a message to the control that it can clear its &quot;throttle date.&quot;

Can anybody think of a better way to discover that tracking has ended from within the control class itself?</description>
		<content:encoded><![CDATA[<p>Good point, Jon. I thought about this briefly but decided that the frequency of my throttle was still so fast that it was unlikely to &#8220;miss&#8221; a final event. I agree it&#8217;s possible though, and probably demands a more robust solution.</p>
<p>One possibility would be to subclass NSSliderCell and, in its &#8220;stopTracking&#8230;&#8221; method, send a message to the control that it can clear its &#8220;throttle date.&#8221;</p>
<p>Can anybody think of a better way to discover that tracking has ended from within the control class itself?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jon</title>
		<link>http://www.red-sweater.com/blog/64/throttling-nsslider/comment-page-1#comment-343</link>
		<dc:creator>Jon</dc:creator>
		<pubDate>Thu, 08 Dec 2005 08:58:08 +0000</pubDate>
		<guid isPermaLink="false">http://www.red-sweater.com/blog/?p=64#comment-343</guid>
		<description>One potential problem with this plan involves the final landing point. It&#039;s one thing to ignore intermediary updates, but another to ignore ending updates.

If you ignore action B based solely on how recently action A was fired, eventually there will be no action C behind it. At this point the control is in state B, while you may still be displaying remnants of state A.

So a more robust implementation might involve an NSTimer after all, to defer the action until after a quiet period has ended.</description>
		<content:encoded><![CDATA[<p>One potential problem with this plan involves the final landing point. It&#8217;s one thing to ignore intermediary updates, but another to ignore ending updates.</p>
<p>If you ignore action B based solely on how recently action A was fired, eventually there will be no action C behind it. At this point the control is in state B, while you may still be displaying remnants of state A.</p>
<p>So a more robust implementation might involve an NSTimer after all, to defer the action until after a quiet period has ended.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Michael Tsai - Blog - Throttling NSSlider</title>
		<link>http://www.red-sweater.com/blog/64/throttling-nsslider/comment-page-1#comment-336</link>
		<dc:creator>Michael Tsai - Blog - Throttling NSSlider</dc:creator>
		<pubDate>Tue, 06 Dec 2005 16:33:16 +0000</pubDate>
		<guid isPermaLink="false">http://www.red-sweater.com/blog/?p=64#comment-336</guid>
		<description>[...] Daniel Jalkut: [...]</description>
		<content:encoded><![CDATA[<p>[...] Daniel Jalkut: [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Daniel Jalkut</title>
		<link>http://www.red-sweater.com/blog/64/throttling-nsslider/comment-page-1#comment-335</link>
		<dc:creator>Daniel Jalkut</dc:creator>
		<pubDate>Tue, 06 Dec 2005 15:26:16 +0000</pubDate>
		<guid isPermaLink="false">http://www.red-sweater.com/blog/?p=64#comment-335</guid>
		<description>Thanks, Ken. I had forgotten about the &quot;only on tick mark&quot; settings. I&#039;m sure in a lot of instances using that setting would provide the desired throttling.</description>
		<content:encoded><![CDATA[<p>Thanks, Ken. I had forgotten about the &#8220;only on tick mark&#8221; settings. I&#8217;m sure in a lot of instances using that setting would provide the desired throttling.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ken</title>
		<link>http://www.red-sweater.com/blog/64/throttling-nsslider/comment-page-1#comment-334</link>
		<dc:creator>ken</dc:creator>
		<pubDate>Tue, 06 Dec 2005 08:16:24 +0000</pubDate>
		<guid isPermaLink="false">http://www.red-sweater.com/blog/?p=64#comment-334</guid>
		<description>There are situations where value doesn&#039;t change as often as the action is sent.. the slider may be constrained to only take values at tick marks, or the user may move his mouse perpendicularly to the slider. .

Anywho, your throttling code seems useful. :-)

One can hit yet another gradation by calling [slider setContinous:NO].  In this situation, you will only receive an action message when the user releases the slider knob.</description>
		<content:encoded><![CDATA[<p>There are situations where value doesn&#8217;t change as often as the action is sent.. the slider may be constrained to only take values at tick marks, or the user may move his mouse perpendicularly to the slider. .</p>
<p>Anywho, your throttling code seems useful. :-)</p>
<p>One can hit yet another gradation by calling [slider setContinous:NO].  In this situation, you will only receive an action message when the user releases the slider knob.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

