I am making a utility that will search for tags in my file. when it finds them, it reports on them.
I have a function that reads all the tags in the file.
I can load them into a table.
I have what code I understand below. I realize it is formatted terribly for lua, but it is how I go about understanding line by line.
I realize this only shows the screen and will not leave the mainloop.
my first and most confounding issue is loading my table into iup.list()
issues:
how do I get from my table and drop that table into iup.list?
how do I show at least part of the list? I thought the visible 4 would show the first 4 (like pagination) until I poked the twistie. at present it shows nothing until I poke the twistie and it shows all 8. I will have more than one page per screen of tags, so I will need to implement a slider (vbox?) in the display.
I will need to implement an ok and cancel button as well.
I expect when I select one I need some cb function to get it.
it will be a single selection. is there a double click and go or do need to click and ok button (that is, does the callback have to be connected to the buttons?
I havent done a great deal with iup, I have made several attempts, but find the documentation massively obscure.
ColeValleyGirl, I read your question and self-answers on this load thing on stack overflow of an instant some 5+ years ago, and was not enlightened.... LOL. It was and is too sophisticated for me at the present time.
Code: Select all
function sltTAG()
local Opt = 0
-- Create a list and set:
-- contents
-- dropdown
-- expansion
-- # of visible items
list_tags = iup.list
{
'TAG1',
'TAG2',
'TAG3',
'TAG4',
'TAG5',
'TAG6',
'TAG7',
'TAG8',
dropdown = 'YES',
expand = 'YES',
visible_items = 4
}
-- Creates frame with dropdown list and sets its title
frame_tags = iup.frame
{
list_tags,
title = 'Drop Down',
size = 'QUARTERxQUARTER'
}
-- Creates a dialog with the frame and sets its title
dlg = iup.dialog
{iup.hbox
{
frame_tags
},
title = 'IupList',
size = 'QUARTERxQUARTER'
}
-- Shows dialog in the center of the screen
dlg:showxy(iup.CENTER, iup.CENTER)
if (iup.MainLoopLevel() == 0) then
iup.MainLoop()
end
if WS_RC == WS_ENTER then
return WS_RC, Opt
end
return WS_CANCEL, ''
end -- fn sltTAG
sltTAG()