Widget Slider Not Working As Expected

Hi,

I’m trying to use Widgets for the first time and I’m trying to implement a slider with the following code:

[lua]module(…, package.seeall);

local widget = require “widget”

function new()

local someGroup = display.newGroup()

local bg = display.newRect( 0, 0, _W, _H)
bg.x = _W * 0.5; bg.y = _H * 0.5;

someGroup:insert( bg)

– Callback listener for slider widget:
local sliderListener = function( event )
local sliderObj = event.target

print( "New value is: " … event.target.value )
end

– Create the slider widget
local mySlider = widget.newSlider{
width=160,
callback=sliderListener
}

– Center the slider widget on the screen:
mySlider.x = display.contentWidth * 0.5
mySlider.y = display.contentHeight * 0.5

– adjust the slider width:
mySlider.width = 240

– set the value manually:
mySlider.value = 75

– insert the slider widget into a group:
someGroup:insert( mySlider.view )

return someGroup

end[/lua]

As you can see I’m using Director with this. I have also downloaded and added the following to my project folder root:

widget_ios/uiSlider/

including all the images of course.
The problem is, although the ends and the handle of the slider are visible, the middle section does not display. The terminal output print statement works correctly and there are no errors showing.

I’m sure it’s a stupid mistake I’ve made somewhere, but why is this happening?

Thanks

[import]uid: 74503 topic_id: 15920 reply_id: 315920[/import]

Anyone?

Just a further note, if I remove the ‘.view’ from line 38 so that it reads:

someGroup:insert( mySlider )

the slider then displays correctly in the simulator but I get a Runtime error.

Thanks to anyone who can help… [import]uid: 74503 topic_id: 15920 reply_id: 58918[/import]

I am seeing the same thing.

It seems that any error that causes director to display an error window will allow the slider to be fully seen.

Ricardo is planning on addressing widgets in Director 1.5
http://developer.anscamobile.com/forum/2011/09/28/director-15-what-do-you-want
[import]uid: 55576 topic_id: 15920 reply_id: 63878[/import]