So I have a problem, I started my first app and got pretty far, I created a button widget which works and showed up in both the corona simulator and the blue stacks simulator.
I added a text field and everything turned out fine in the corona simulator, but when it was time to test the text field in the bluestacks simulator as soon as I started the app, there was a text field but the button was gone, Im not sure why that is happening.
Also while developing I have the corona simulator in galaxy s3 mode and it looks great, everything is as it should be, when I change the corona simulator to iphone or ipad, everything stays at it should but the button moves to the right. Im not sure why.
The code,
--Requires --widget = require ( "widget" ) local widget = require "widget-v1" --Set constant width and height of screen. \_W = display.viewableContentWidth \_H = display.viewableContentHeight --Create white background local background = display.newRect(0,0,\_W, \_H) background:setFillColor ( 70,130,180 ) --End Basic Stuff --Result Text dbText = ("db Loss") rText = display.newText (dbText,0, 0, helvetica, 42) rText:setTextColor(255,255,255) rText.x = \_W \* .5 rText.y = \_H -100 -- Variables Needed local distanceData = 2 local connData = 5 local spliceData = 1 local distLoss = 3.5 local conLoss = .75 local spliceLoss = 0.3 --end variables --Field Texts Title Start local dlTitle = display.newText( "Average Distance Loss", 0, 0, helvetica, 24 ) dlTitle.x = \_W \* .5 dlTitle.y = \_H \* .05 local clTitle = display.newText( "Average Connector Loss", 0, 0, helvetica, 24 ) clTitle.x = \_W \* .5 clTitle.y = dlTitle.y +150 local slTitle = display.newText( "Average Splice Loss", 0, 0, helvetica, 24 ) slTitle.x = \_W \* .5 slTitle.y = clTitle.y +150 local dTitle = display.newText( "Cable Distance", 0, 0, helvetica, 24 ) dTitle.x = \_W \* .5 dTitle.y = slTitle.y + 150 local cTitle = display.newText( "Number of Connectors", 0, 0, helvetica, 24 ) cTitle.x = \_W \* .5 cTitle.y = dTitle.y+150 local sTitle = display.newText( "Average Distance Loss", 0, 0, helvetica, 24 ) sTitle.x = \_W \* .5 sTitle.y = cTitle.y + 150 --Field Title End --Fields Start local gotEnd = false local function getData(event) end distField = native.newTextField(\_W \* .23, dlTitle.y + 25, \_W - 300,50) distField:addEventListener ("userInput", getData) distField.font = "helvetica" distField.size = 24 distField:setTextColor(51,51,122,255) --Fields End --Main Function function resulter (d,c,s,dl,cl,sl) rText.text = "" local r d = d \* dl c = c \* cl s = s \* sl r = (d + c) + s print (r) local resultIs = r local dbText = ("db Loss: " .. resultIs) local rText = display.newText (dbText, 0, 0, helvetica, 42) rText:setTextColor(255,255,255) rText.x = \_W \* .5 rText.y = \_H -100 end --Event Handlers local function btnOnPressHandler() resulter(distanceData, connData, spliceData, distLoss, conLoss, spliceLoss ) end local function btnOnReleaseHandler() print ("Released") end --endEvent Handlers local button = widget.newButton( { id= "button 1", left = 0, top = 0, label = "Calculate Loss", width = 256, height = 56, font = Helvetica, fontSize = 27, labelColor = { default={0,0,0}, over= {255,255,255} }, defaultColor={201,107,61}, overColor = {219,146,85}, onPress = btnOnPressHandler , onDrag = btnOnDragHandler, onRelease = btnOnReleaseHandler }) button.x = display.actualContentWidth /2 button.y = display.actualContentHeight \*.8 --resulter(distanceField, connField, spliceField, distLoss, conLoss, spliceLoss) print ("x position is " .. button.x) print ("y position is " .. button.y) print ("button x position is" .. background.x) print ("button y position is" .. background.y)