• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Cascading menus

LEGEND ,
Jan 19, 2017 Jan 19, 2017

Copy link to clipboard

Copied

I just accidentally stumbled on how to make cascading popup menus -- you nest the items passed to popup_menu() in the (now) obvious way:

local LrBinding = import 'LrBinding'

local LrDialogs = import 'LrDialogs'

local LrFunctionContext = import 'LrFunctionContext'

local LrView = import 'LrView'

local bind = LrView.bind

local f = LrView.osFactory()

local items = {

    {title = "Item 0", value = "0"},

    {title = "Item 1",

        {title = "Item 1.a", value = "1.a"},

        {title = "Item 1.b", value = "1.b"}},

    {title = "Item 2",

        {title = "Item 2.a", value = "2.a"},

        {title = "Item 2.b", value = "2.b"}}}

LrFunctionContext.callWithContext ("", function (context)

    local prop = LrBinding.makePropertyTable (context)

    LrDialogs.presentModalDialog {title = "Nested Menu",

        contents = f:popup_menu {items = items, value = bind ("v"),

            bind_to_object = prop}}

    LrDialogs.message ("Selected item", prop.v)

    end)

Here's what it looks like:

This is undocumented, so who knows whether it will remain "supported" in future versions (as much as anything in the SDK is "supported" these days).

TOPICS
SDK

Views

237

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
no replies

Have something to add?

Join the conversation