DICE PACKS BUNDLE
  1. #1

    Text FIelds on a Popup

    I have managed to muddle my way through part of creating an extension that will allow a person to enter text into two fields and press a button to pass those values to a function that does a web query for some information.

    I have my popup working with some basic instructions and a button at the bottom of the popup. I have been unable to decipher the FGU API docs to figure out how to put some simple labels and the fields for the information I want to capture onto the popup and was hoping someone could help.

    Here is my code for this thus far:
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <root>
        <windowclass name="UWPImport">
            <frame>utilitybox</frame>
            <sizelimits>
                <minimum width="400" height="300" />
                <dynamic />
            </sizelimits>
            <sheetdata>
                <!-- Title -->
                <windowtitlebar_utilitybox name="title">
                    <text>UWP Import Tool</text>
                </windowtitlebar_utilitybox>
                <windowmenubar_utilitybox name="menubar" />
                <anchor_content_utilitybox_top />
                <anchor_content_utilitybox_bottom />
    
                <!-- Instructions -->
                <stringc_content_framed_groupbox_top name="instructions">
                    <static>Enter the Sector and Hex location for the world, then click 'Retrieve'.
                    </static>
                    <readonly />
                    <nodrag />
                </stringc_content_framed_groupbox_top>
    
                <!-- Sector Label -->
                <label name="sector_label">
                <font>emotefont</font>
                    <bounds left="20" top="100" width="100" height="20" />
                    <text>Sector:</text>
                </label>
    
                <!-- Sector Input -->
                <stringfield name="sector_input">
                    <bounds left="130" top="100" width="200" height="20" />
                </stringfield>
    
                <!-- Hex Label -->
                <label name="hex_label">
                <font>emotefont</font>
                    <bounds left="20" top="140" width="100" height="20" />
                    <text>Hex:</text>
                </label>
    
                <!-- Hex Input -->
                <stringfield name="hex_input">
                    <bounds left="130" top="140" width="200" height="20" />
                </stringfield>
    
                <!-- Retrieve Button -->
                <button_text_content_center_bottom name="retrievebutton">
                    <text>Retrieve</text>
                    <onClick>
                        local sector = window.getChild("sector_input").getValue();
                        local hex = window.getChild("hex_input").getValue();
                        UWPManager.retrieveWorldData(sector, hex);
                    </onClick>
                </button_text_content_center_bottom>
            </sheetdata>
        </windowclass>
    </root>
    I get no errors in the console or anything once the popup comes up, so am not sure where to go. I have also tried <stringcontrol> in place of <stringfield> to no avail.

  2. #2
    Here's how I would do it. I've attached the mini-extension I used to test using /uwpimport chat command to bring up window.

    Code:
    	<windowclass name="UWPImport">
    		<frame>utilitybox</frame>
    		<sizelimits>
    			<minimum width="400" height="300" />
    			<dynamic />
    		</sizelimits>
    		<sheetdata>
    			<!-- Title -->
    			<windowtitlebar_utilitybox name="title">
    				<static>UWP Import Tool</static>
    			</windowtitlebar_utilitybox>
    			<windowmenubar_utilitybox name="menubar" />
    
    			<anchor_content_utilitybox_top />
    			<anchor_content_utilitybox_bottom />
    
    			<!-- Instructions -->
    			<stringc_content_framed_groupbox_top name="instructions">
    				<static text="Enter the Sector and Hex location for the world, then click 'Retrieve'." />
    				<nodrag />
    			</stringc_content_framed_groupbox_top>
    
    			<!-- Retrieve Button -->
    			<button_text_content_center_bottom name="retrievebutton">
    				<text>Retrieve</text>
    				<script>
    					function onButtonPress()
    						local sector = window.fields.subwindow.sector_input.getValue();
    						local hex = window.fields.subwindow.hex_input.getValue();
    						UWPManager.retrieveWorldData(sector, hex);
    					end
    				</script>
    			</button_text_content_center_bottom>
    
    			<!-- Fields -->
    			<sub_content_framed_groupbox name="fields">
    				<class>UWPImportContent</class>
    			</sub_content_framed_groupbox>
    
    			<resize_utilitybox />
    		</sheetdata>
    	</windowclass>
    	<windowclass name="UWPImportContent">
    		<margins control="0,0,0,2" />
    		<sheetdata>
    			<anchor_content_top />
    
    			<!-- Sector -->
    			<label_content_column name="sector_label">
    				<static text="Sector:" />
    			</label_content_column>
    			<stringc_content_column_single name="sector_input" />
    
    			<!-- Hex -->
    			<label_content_column name="hex_label">
    				<static text="Hex:" />
    			</label_content_column>
    			<stringc_content_column_single name="hex_input" />
    		</sheetdata>
    	</windowclass>
    Regards,
    JPG
    Attached Files Attached Files

  3. #3
    Thank you for this. Is it actually possible to truly implement what I am trying? I am not actually sure I cant take the data from my form, create a URL, query the website, and then import that JSON data back into FGU. I seem to remember sometime back that this kind of thing was disallowed for some reason. I had gotten the LUA code working to process JSON pasted into a field manually, but automating it like I wanted would be simpler.

  4. #4
    You can use the following API: Interface.openURL(url, callbackfunction)
    where the callback function is of the form: function callbackfunction(sURL, sResponse)

    It's actually used in the Syrinscape sound links coding in CoreRPG to import Syrinscape sound data. You can run a search over CoreRPG files to see how it is used there.

    Regards,
    JPG

  5. #5
    Awesome. Thanks for the help on the form.

    I have already changed the form I had made to paste in the JSON I had working back over to be Sector and Hex data, where it will automatically retrieve the JSON data from the website. I have completed and submitted an extension (my first) to the Forge. Here is the thread for it: https://www.fantasygrounds.com/forum...eb-Import-Tool
    Last edited by Stargrove; December 4th, 2024 at 02:09.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
5E Character Create Playlist

Log in

Log in