cfg.Fast and Drawer problem

106 views
Skip to first unread message

wheelie tips

unread,
Dec 7, 2022, 11:58:03 PM12/7/22
to DroidScript
Hello, adding cfg.Fast to an existing project causes the Drawer to ignore the user swipes, for example:

cfg.Fast

//Called when application is started.
function OnStart()
{    
    //Lock screen orientation to Portrait.
    app.SetOrientation( "Portrait" )
   
    //Create the main app layout with objects vertically centered.
    layMain = app.CreateLayout( "Linear", "VCenter,FillXY" )
    layMain.SetBackground( "/Res/drawable/android" )

    //Create a text label and add it to main layout.
    txt = app.CreateText( "<-- swipe from left" )
    txt.SetTextSize( 24, "dip" )
    layMain.AddChild( txt )
   
    //Create a drawer containing a menu list.
    CreateDrawer()
   
    //Add main layout and drawer to app.    
    app.AddLayout( layMain )
    app.AddDrawer( drawerScroll, "Left", drawerWidth )
}

//Create the drawer contents.
function CreateDrawer()
{
    //Create a layout for the drawer.
    //(Here we also put it inside a scroller to allow for long menus)
    drawerWidth = 0.75;
    drawerScroll = app.CreateScroller( drawerWidth, -1, "FillY" )
    drawerScroll.SetBackColor( "White" )
    layDrawer = app.CreateLayout( "Linear", "Left" )
    drawerScroll.AddChild( layDrawer )
   
    //Create layout for top of drawer.
    layDrawerTop = app.CreateLayout( "Absolute" )
    layDrawerTop.SetBackground( "/Sys/Img/GreenBack.jpg" )
    layDrawerTop.SetSize( drawerWidth, 0.23 )
    layDrawer.AddChild( layDrawerTop )
   
    //Add an icon to top layout.
    var img = app.CreateImage( "/Sys/Img/Icon.png", 0.15 )
    img.SetPosition( drawerWidth*0.06, 0.04 )
    layDrawerTop.AddChild( img )
   
    //Add user name to top layout.
    var txtUser = app.CreateText( "Dave Smart",-1,-1,"Bold")
    txtUser.SetPosition( drawerWidth*0.07, 0.155 )
    txtUser.SetTextColor( "White" )
    txtUser.SetTextSize( 13.7, "dip" )
    layDrawerTop.AddChild( txtUser )
   
    //Add user email to top layout.
    txtEmail = app.CreateText( "da...@droidscript.org")
    txtEmail.SetPosition( drawerWidth*0.07, 0.185 )
    txtEmail.SetTextColor( "#bbffffff" )
    txtEmail.SetTextSize( 14, "dip" )
    layDrawerTop.AddChild( txtEmail )
   
    //Create menu layout.
    var layMenu = app.CreateLayout( "Linear", "Left" )
    layDrawer.AddChild( layMenu )
   
    //Add a list to menu layout (with the menu style option).
    var listItems = "Primary::[fa-home],Social::[fa-users],Promotions::[fa-tag]";
    lstMenu1 = app.CreateList( listItems, drawerWidth, -1, "Menu,Expand" )
    lstMenu1.SetColumnWidths( -1, 0.35, 0.18 )
    lstMenu1.SelectItemByIndex( 0, true )
    lstMenu1.SetItemByIndex( 0, "Primary", 21 )
    lstMenu1.SetOnTouch( lstMenu_OnTouch )
    layMenu.AddChild( lstMenu1 )
   
    //Add seperator to menu layout.
    var sep = app.CreateImage( null, drawerWidth,0.001,"fix", 2,2 )
    sep.SetSize( -1, 1, "px" )
    sep.SetColor( "#cccccc" )
    layMenu.AddChild( sep )
   
    //Add title between menus.
    txtTitle = app.CreateText( "All labels",-1,-1,"Left")
    txtTitle.SetTextColor( "#666666" )
    txtTitle.SetMargins( 16,12,0,0, "dip" )
    txtTitle.SetTextSize( 14, "dip" )
    layMenu.AddChild( txtTitle )
   
    //Add a second list to menu layout.
    var listItems = "Starred::[fa-star],Important::[fa-flag],Settings::[fa-cog]";
    lstMenu2 = app.CreateList( listItems, drawerWidth, -1, "Menu,Expand" )
    lstMenu2.SetColumnWidths( -1, 0.35, 0.18 )
    lstMenu2.SetOnTouch( lstMenu_OnTouch )
    layMenu.AddChild( lstMenu2 )
}

//Handle menu item selection.
function lstMenu_OnTouch( title, body, type, index )
{
    //Close the drawer.
    app.CloseDrawer( "Left" )
   
    //Highlight the chosen menu item in the appropriate list.
    if( this==lstMenu1 ) lstMenu2.SelectItemByIndex(-1)
    else lstMenu1.SelectItemByIndex(-1)
    this.SelectItemByIndex( index, true )
   
    app.ShowPopup( title )
}
////////////////////////////////////////////////////////////////////////////////////

any thoughts on how to make it work?
cheers,
WT

wheelie tips

unread,
Dec 8, 2022, 4:47:42 AM12/8/22
to DroidScript
well, apparently, it has nothing to do with the cfg.Fast, after upgrading to ver 2.57 the drawer doesn't work.

Steve Garman

unread,
Dec 8, 2022, 5:07:58 AM12/8/22
to DroidScript
I think you'll find it is a cfg.Fast problem

You can't just comment cfg.Fast our. You need to ensure the string isn't in the source anywhere

wheelie tips

unread,
Dec 8, 2022, 5:10:00 AM12/8/22
to DroidScript
you're right :)
it is a cfg.Fast related problem.

Tjerk Herckenrath

unread,
Dec 8, 2022, 6:46:23 AM12/8/22
to DroidScript
It's not just a cfg.Fast problem - 
drawer doesn't respond to clicks when using cfg.Node.

Adding cfg.Node to the Drawer Menu sample causes it to 
no longer function.

Alan Hendry

unread,
Dec 8, 2022, 6:59:26 AM12/8/22
to DroidScript
Hi,
I reported that drawer doesn't work in hybrid in the beta group.
I think it gave me an error (function createdrawer not found).
Does opendrawer work?
Regards, ah

Tjerk Herckenrath

unread,
Dec 8, 2022, 8:51:22 AM12/8/22
to DroidScript
With cfg.Node the drawer will show and can be 
dismissed and taps on the menu items have no 
effect other than the visual feedback.

Dave

unread,
Jan 7, 2023, 1:28:03 PM1/7/23
to DroidScript
Here is a work-around for the cfg.Fast and drawer problem - 

We need to delay the AddDrawer call till after the app is displayed like this - 

setTimeout( ()=>{app.AddDrawer( drawerScroll, "Left", drawerWidth )}, 0 )

Not sure why, but will investigate

wheelie tips

unread,
Jan 10, 2023, 10:33:27 AM1/10/23
to DroidScript

@Dave - thanks much for the workaround; it works well!
Message has been deleted

Tjerk Herckenrath

unread,
Jan 21, 2023, 12:52:34 PM1/21/23
to DroidScript
I'm happy to report that the cfg.Node issue with drawer appears to be fixed in the latest beta :-)
Reply all
Reply to author
Forward
0 new messages