Skip to main content
Participant
June 25, 2012
Question

Dynamic table for popup_menu

  • June 25, 2012
  • 2 replies
  • 1937 views

I'm trying to attach some dynamic information to a popup_menu (pulldown) object in the export dialog.

I'm retrieving the data through an asynchronous task such as:

SYPNEventResults = '';

local LrDialogs = import "LrDialogs"

local LrHttp = import "LrHttp"

import "LrTasks".startAsyncTask( function()    

    SYPNEventResults, hdrs = LrHttp.get( "http://dev.seeyourphotos.net/cgi-bin/lightroom-event-list.cgi?photographer_id=20060207")

end )

This does succcessfully query the server and place a chunk of values in the SYPNEventResults variable like this:

{ title = "Lab Event", value = "Lab Event" },

{ title = "Karsten", value = "Karsten" },

When I try to use this to populate the contents of the pulldown object (below), what is shown is all of the

values as one long string rather than a list of events to choose from.  I'm presuming I'm missing a setp to

bind this somehow differently.

viewFactory:popup_menu {

        items = {

            SYPNEventResults

        },

       value = LrView.bind('eventname2'),

       width_in_chars = 40,

},

In summary, I'm trying to popuulate a custom dialog pulldown where the user selects from an event list retrieved from the server where that value can in turn be used in other parts of the dialog/ftp upload.

I'm new to Lightroom, so please take that into account in your answer.

Thanks in advance for any help.

This topic has been closed for replies.

2 replies

Blatman888
Participating Frequently
June 25, 2012

Ed,

I had a similar result when I was doing font selection with a popup in the webengine - from memory the line of tables was produced when part of a string rather than a table. The items parameter is a table of tables but I had made a string of tables.

Maybe try SYPNEventResults = {},  

Cheers,

Blane

Participant
June 25, 2012

I definitely feel like what is being returned is a string of tables rather than a table of tables.

LrDialogs.message( SYPNEventResults[1].title ) returns an error.

Any quick help on how to covert from a string of tables to a table of tables?

Thanks in advance.  I'm trying to read up as much as I can but it's a bit like drinking from a fire hydrant at the moment.

areohbee
Legend
June 25, 2012

There is no such thing as a string of tables, only string of characters, but I recommend using

* type( variable ) to assertain variable type, and/or

* John Ellis' Debug.lognpp - to dump variables and subvariables ad-infinitum with table syntax trimming... - so you can see exacty what you've got.

http://forums.adobe.com/message/4141424

If the return variable is a string of characters, and no way around that (i.e. server is doing it, not plugin), you may need to parse the string into pieces and assign pieces to table members, to come up with popup 'items' table in proper form.

R

areohbee
Legend
June 25, 2012

I've never used dynamically changing popup items variable before, and I'm not sure it will work(?)

But, if it's displaying a long string, it does not sound like 'items' is being assigned a proper table yet.

I don't know what you mean by a  "chunk" of values. I assume you mean table.

In any case, if SYPNEventResults[1].title is a string, then SYPNEventResults[1].value can be any legal lua type.

Likewise for SYPNEventResults[2], SYPNEventResults[3], ...

If you can index/display the title with this syntax, e.g. LrDialogs.message( SYPNEventResults[1].title ), then the popup should be initialized thusly:

viewFactory:popup_menu {

       items = SYPNEventResults,

       value = LrView.bind('eventname2'),

       width_in_chars = 40,

},

if a function is returning multiple values, then to get it into a table "array", do this:

local tableArray = { myTableArrayFunc( myTableArrayParameters ) }

Does this help?


Rob