This shows you the differences between two versions of the page.
sample_code:slide_menu [2015/09/25 07:59] stevegarman created |
sample_code:slide_menu [2019/03/02 11:42] |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Slide Menu ====== | ||
- | You can swipe left to close this menu. | ||
- | <code JavaScript swipeMenu.js> | ||
- | var layMenu, | ||
- | // | ||
- | function OnStart() | ||
- | { | ||
- | app.SetOrientation(" | ||
- | app.EnableBackKey(false); | ||
- | // | ||
- | var layMain=app.CreateLayout(" | ||
- | layMain.SetBackColor("# | ||
- | layMain.SetPosition(0, | ||
- | app.AddLayout(layMain); | ||
- | var lay=app.CreateLayout(" | ||
- | var btnMnu; | ||
- | if(app.GetDSVersion()> | ||
- | { | ||
- | btnMnu=app.CreateButton(" | ||
- | btnMnu.SetStyle( "# | ||
- | } | ||
- | else | ||
- | btnMnu=app.CreateButton(" | ||
- | btnMnu.SetOnTouch(mnuAnimate); | ||
- | lay.AddChild(btnMnu); | ||
- | txe =app.CreateTextEdit(" | ||
- | txe.SetMargins(0.05, | ||
- | txe.SetBackColor("# | ||
- | lay.AddChild(txe); | ||
- | layMain.AddChild(lay); | ||
- | // | ||
- | layMenu = app.CreateLayout( " | ||
- | layMenu.SetPosition(0, | ||
- | layMenu.SetBackColor("# | ||
- | layMenu.SetVisibility(" | ||
- | // | ||
- | lst = app.CreateList( "" | ||
- | lst.SetOnTouch(lst_OnTouch); | ||
- | lst.SetList(null); | ||
- | lst.AddItem(" | ||
- | lst.AddItem(" | ||
- | lst.AddItem(" | ||
- | lst.AddItem(" | ||
- | layMenu.AddChild( lst ); | ||
- | // | ||
- | var img=app.CreateImage(null, | ||
- | img.downX=0 | ||
- | img.SetOnTouch(swipeTest); | ||
- | layMenu.AddChild(img); | ||
- | |||
- | // | ||
- | layMain.AddChild( layMenu ); | ||
- | } | ||
- | |||
- | function mnuAnimate() | ||
- | { | ||
- | if(layMenu.GetVisibility()===" | ||
- | layMenu.Animate(" | ||
- | else | ||
- | layMenu.Animate(" | ||
- | } | ||
- | |||
- | function swipeTest(ev) | ||
- | { | ||
- | if(ev.action===" | ||
- | { | ||
- | this.downX=ev.X; | ||
- | } | ||
- | if(ev.action===" | ||
- | { | ||
- | if(ev.X-this.downX < | ||
- | layMenu.Animate(" | ||
- | else | ||
- | app.SimulateTouch(lst, | ||
- | } | ||
- | } | ||
- | |||
- | function lst_OnTouch( title, | ||
- | { | ||
- | var s = txe.GetText()+" | ||
- | txe.SetText(s); | ||
- | app.ShowPopup(title+" | ||
- | } | ||
- | |||
- | function OnBack() | ||
- | { | ||
- | if(layMenu.GetVisibility()===" | ||
- | layMenu.Animate(" | ||
- | else app.Exit(); | ||
- | } | ||
- | |||
- | </ |