In Glide, Dropdown not working

Hi everybody,

I am trying to use Glide in my Fez Spider kit and while buttons and text boxes work fine, I am having serious trouble with the Dropdown element, I can’t make it work.

This is the XML generated in the Glide designer:

Label0 Label1

Very simple screen with a dropdown control at the center with just two options. This is the C# code of a very simple application that just shows the Dropdown:


using System;
using System.Collections;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Presentation;
using Microsoft.SPOT.Presentation.Controls;
using Microsoft.SPOT.Presentation.Media;
using Microsoft.SPOT.Presentation.Shapes;
using Microsoft.SPOT.Touch;

using Gadgeteer.Networking;
using GT = Gadgeteer;
using GTM = Gadgeteer.Modules;
using Gadgeteer.Modules.GHIElectronics;
using GHI.Glide;
using GHI.Glide.Display;
using GHI.Glide.UI;

namespace TestDropdown
{
    public partial class Program
    {
        private static GHI.Glide.Display.Window mainWindow;

        // This method is run when the mainboard is powered up or reset.   
        void ProgramStarted()
        {
            /*******************************************************************************************
            Modules added in the Program.gadgeteer designer view are used by typing 
            their name followed by a period, e.g.  button.  or  camera.
            
            Many modules generate useful events. Type +=<tab><tab> to add a handler to an event, e.g.:
                button.ButtonPressed +=<tab><tab>
            
            If you want to do something periodically, use a GT.Timer and handle its Tick event, e.g.:
                GT.Timer timer = new GT.Timer(1000); // every second (1000ms)
                timer.Tick +=<tab><tab>
                timer.Start();
            *******************************************************************************************/


            // Use Debug.Print to show messages in Visual Studio's "Output" window during debugging.
            Debug.Print("Program Started");

            mainWindow = GlideLoader.LoadWindow(Resources.GetString(Resources.StringResources.mainWindow));

            Dropdown dd = (Dropdown)mainWindow.GetChildByName("drop");

            dd.TapEvent += dd_TapEvent;


            GlideTouch.Initialize();

            Glide.MainWindow = mainWindow;
        }

        void dd_TapEvent(object sender)
        {
            Debug.Print("TAP");
        }
    }
}

Of course, I added the XML as a string resource as explained in the Guide tutorial. When I start the device, the LCD shows the dropdown control (strangely with the arrow upside down) (see dropdown1 picture) and when I tap on the control I don’t see the options and therefore I can’t select any option (however the arrow is not upside down while tapped, see dropdown2 picture).

I have tried a lot of things and I have spent my entire afternoon trying to figure out what is wrong. For example I tried adding items dinamically, because I want to use the dropdown to visualize Wifi networks If anybody has any idea what is wrong please let me know.

These are the specs of my setup:

I am using Visual Studio 2012 Express on Windows 7 64 bits. This is the firmware I have:
Loader (TinyBooter) version information:
4.3.4.0 on this computer.
4.3.4.0 on this device.

The Loader (TinyBooter) is up to date. <<<

Firmware (TinyCLR) version information:
4.3.6.0 on this computer.
4.3.6.0 on this device.

The Firmware (TinyCLR) is up to date. <<<

Any help will be greatly appreciated!

Kind regards,
Federico

1 Like

Look for the file called DropdownExample.xml as this shows how to use it.

You need to create a list and then call Glide.OpenList(sender, list) to show the list in the OnTap event. Here’s the code from the sample.

        static void InitWin()
        {
            // Get the Dropdown
            Dropdown dropdown = (Dropdown)window.GetChildByName("dropdown");
            dropdown.TapEvent += new OnTap(dropdown_TapEvent);
            dropdown.ValueChangedEvent += new OnValueChanged(dropdown_ValueChangedEvent);

            // Create the list that the Dropdown uses...
            list = new List(dropdown.Options, 150);
            
            // Or you can provide your own options
            /*
            ArrayList options = new ArrayList()
            {
                // Each object array contains Label, Data
                new object[2] { "Option #1", 1 },
                new object[2] { "Option #2", 2 },
                new object[2] { "Option #3", 3 },
                new object[2] { "Option #4", 4 },
                new object[2] { "Option #5", 5 }
            };
            list = new List(options, 150);
            */
            
            list.CloseEvent += new OnClose(list_CloseEvent);
        }

        // When the Dropdown is tapped it will open it's list.
        static void dropdown_TapEvent(object sender)
        {
            Glide.OpenList(sender, list);
        }

        // This shows when the Dropdown's value changes.
        static void dropdown_ValueChangedEvent(object sender)
        {
            Dropdown dropdown = (Dropdown)sender;
            Debug.Print("Dropdown value: " + dropdown.Text + " : " + dropdown.Value.ToString());
        }

        static void list_CloseEvent(object sender)
        {
            Glide.CloseList();
        }

1 Like

Thank you Dave, it works now! The DropdownExample.xml where this is documented was not easy to find, so far I found it here:

Is there an easier way to find documentation about using Glide? The document provided here:

https://www.ghielectronics.com/docs/315/glide

is very basic. Thank you for your kind help.

Best regards,
Federico