Home   Archive   Permalink



RebGUI Screens in Objects - How to Access Widget Values?

Perpetual Newbie here - I wanted to take a stab @ building a small RebGUI app, and I thought it would be cleaner if I used objects to contain my various screen definitions,e.g.:
    
;home screen
home: make object! [
title: "RSB Home"
spec: compose/only [group-box {Choose Study} data [tl: text-list data (sql/flat {select distinct study from main order by study}) return button "Go!" [alert to-string tl/selected]]
group-box {Other Actions} data [button "Import New RSB File" 50 [alert "TBD"] return button "Quit" 50 255.0.0 [QUIT]]]
closer: [Question "Quit Application?"]
]
    
with those alert calls in ther for now just to see that things are working. So this is OK, I can display my screen with:
    
display/close home/title home/spec home/closer
do-events
    
and that is all good - but I am stuck on how I would use access the value selected from the text-list (tl/selected) for the next screen I would want to go. In this example, I would want the "Go!" button to open a screen with a table listing all of the records from my "main" table filtered to just the selected study. I was hoping I could reference the value from my home object, e.g., as "home/selected-study", but have no idea how to tie such an object variable to the text-list selection.
    
I hope this makes some sort of sense! Thanks in advance for any suggestions.
    


posted by:   JackKort     9-Feb-2018/17:06:32-8:00



You can refer to the data in your text-list object with tl/selected (you don't need another object definition to refer to that selection). It looks like your attention should be focused on how to structure/access your data (rather than creating an object to contain the layout). Here's your example without the 'home object, to clarify how to work the RebGUI's text-list widget, and a potential series data structure to satisfy your needs. BTW, the text-list shouldn't contain a text value, just the series you want displayed in the list (there are some other options, but none that is a text value - see http://www.dobeash.com/RebGUI/widgets.html ). Maybe this is a helpful starting point:
    
R E B O L []
months: [
    "January" [1 2 3]
    "February" [2 3 4]
    "March" [3 4 5]
    "April" [4 5 6]
    "May" [5 6 7]
    "June" [6 7 8]
    "July" [7 8 9]
    "August" [8 9 10]
    "September" [10 11 12]
    "October" [11 12 13]
    "November" [12 13 14]
    "December" [13 14 15]
]
do %rebgui.r
title: "RSB Home"
closer: [Question "Quit Application?"]
spec: [
    group-box {Choose Study} data [
     text {select distinct study from main order by study}
     return
     tl: text-list data (extract months 2)
     return
     button "Go!" [
        display "" [
         text-list data (select months tl/selected)
        ]
     ]
    ]
    group-box {Other Actions} data [
     button "Import New RSB File" 50 [alert "TBD"]
     return
     button "Quit" 50 255.0.0 [QUIT]
    ]
]
display/close title compose/only spec closer
do-events

posted by:   Nick     10-Feb-2018/6:51:55-8:00



To be clear, now you can wrap your GUI specs in an object (if for example, you want to manage the namespace more carefully), but it's not required, and that doesn't change how you access/display data from your data structure.
    
R E B O L []
months: [
    "January" [1 2 3]
    "February" [2 3 4]
    "March" [3 4 5]
    "April" [4 5 6]
    "May" [5 6 7]
    "June" [6 7 8]
    "July" [7 8 9]
    "August" [8 9 10]
    "September" [10 11 12]
    "October" [11 12 13]
    "November" [12 13 14]
    "December" [13 14 15]
]
do %rebgui.r
home: make object! [
    title: "RSB Home"
    closer: [Question "Quit Application?"]
    spec: [
     group-box {Choose Study} data [
        text {select distinct study from main order by study}
        return
        tl: text-list data (extract months 2)
        return
        button "Go!" [
         display "" [
            text-list data (select months tl/selected)
         ]
        ]
     ]
     group-box {Other Actions} data [
        button "Import New RSB File" 50 [alert "TBD"]
        return
        button "Quit" 50 255.0.0 [QUIT]
     ]
    ]
]
display/close home/title compose/only home/spec home/closer
do-events

posted by:   Nick     10-Feb-2018/6:56:49-8:00



Thanks Nick! Not just for this response, but for all you do for the REBOL/Red community.
    
You touched on exactly my concern - managing the namespace. That is why I was hoping the text-list would or could be restricted in scope to the "home" object. Sounds like instead I have to give unique names to every text-list I'll use across screens, which I can do, but not as clean as I was hoping I could be.
Again, thank you and best regards!

posted by:   JackKort     12-Feb-2018/10:41:05-8:00