Skip to content

Instantly share code, notes, and snippets.

@robertwahler
Created December 28, 2012 17:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robertwahler/4399957 to your computer and use it in GitHub Desktop.
Save robertwahler/4399957 to your computer and use it in GitHub Desktop.
Modified hannappe sample showing layout resize issue. Run this sample and use the mouse to change the window size. It works when making the window bigger. When you make the window smaller, the buttons don't change alignment. hanappe/projects/hanappe-samples/src/samples/gui/button_sample.lua
module(..., package.seeall)
function onCreate(params)
view = View {
scene = scene,
layout = {
VBoxLayout {
align = {"center", "center"},
padding = {10, 10, 10, 10},
}
},
children = {{
Button {
name = "startButton",
text = "はじめ",
onClick = onStartClick,
},
Button {
name = "backButton",
text = "戻る",
onClick = onBackClick,
},
Button {
name = "testButton1",
text = "disabled",
enabled = false,
},
}},
}
view:updateComponent()
MOAIGfxDevice.setListener(MOAIGfxDevice.EVENT_RESIZE, onResize)
end
function onResize(width, height)
print("onResize(width, height)", width, height)
Application.screenWidth = width
Application.screenHeight = height
Application.viewWidth = width
Application.viewHeight = height
-- resize main view
view:setSize(width, height)
view:getLayer():setSize(width, height)
view:updateLayout()
end
function onStartClick(e)
print("onStartClick")
end
function onBackClick(e)
SceneManager:closeScene({animation = "fade"})
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment