STAR TREK 2d20
Page 1 of 3 123 Last
  1. #1

    Piggy backing a "windowreferencecontrol"

    I'm looking to override the default activate() function but it's protected. The main goal is to perform some logic when the windowreference is activated, for instance, updating several panels or setting some values.

    My usecase is a ship control panel, opening subsystems of a ship to access their details will update a desktop panel element of that subsystem's layout automatically, making the desktop panel serve as an 'info panel' of sorts in the context of the opened windowreference. I ideally want to have a single piece of logic on the trigger point, rather than have separate scripts for each window class when opened given how similar it is save for a few datum I can easily grab in the windowreference itself.

  2. #2

    Join Date
    Apr 2008
    Location
    Virginia Beach
    Posts
    3,096
    KenL, you keep running across the same things that limit what you can do through the API, and this is another of them. I have found no way to synthesize this thing you want.

    MW, if you are listening, please add to FGU:
    onFocus
    onActivate [windows]
    onTime
    onLostFocus
    onDeactivate [windows]
    getTime
    for formattedtextcontrols:
    getSelection
    getSelectionLength
    setSelection
    setSelectionLength
    getCursor
    setCursor
    for text control:
    getSelectionLength
    setSelectionLength
    getCursorIcon
    setCursorIcon
    imagecontrols letting you specify the filename of the image rather than some hard-coded image resource [or] the ability to add a resource definition at runtime from a file location.
    import .txt file into string
    export string into .txt file

    I would add these to the wish list (many of them are already there), but they never get any votes because no one but us modders understand the need for them.
    Last edited by Bidmaron; January 1st, 2018 at 18:32.

  3. #3
    pindercarl's Avatar
    Join Date
    Jan 2015
    Posts
    974
    Blog Entries
    2
    Bidmaron.

    The Wishlist isn't just useful to generate votes, but also provides an index of features requested. It's easier to look at and search the Wishlist than it is to remember that there is a thread somewhere in the forums. John and I do look at the Wishlist, so it would be helpful to add this there. Thanks.

  4. #4
    I managed to do this. I'll post a small example in the next couple days (have to go to work soon). It have its caveats, but I manage to do anything I want with a link (which are mostly windowreferencecontrols).
    I never claimed to be sane. Besides, it's more fun this way.

  5. #5

    Join Date
    Apr 2008
    Location
    Virginia Beach
    Posts
    3,096
    Wow, Nickademus, my hat's off to you. Looking forward to seeing it.

  6. #6

    Join Date
    Apr 2008
    Location
    Virginia Beach
    Posts
    3,096
    I posted a list of requested API calls on Idea Informer here. Please give it a vote.

  7. #7
    Usually, in these scenarios when I want something different than a built-in control, I create a brand new control template using genericcontrol as a base.

    Cheers,
    JPG

  8. #8
    I needed something that could be embedded in the formattedtext. I don't believe we have any control over anything inside the formattedtextcontrol.
    I never claimed to be sane. Besides, it's more fun this way.

  9. #9
    No. Though you can intercept links using the onLinkActivated event for formattedtextcontrols. I use this for reference manuals.

    Regards,
    JPG

  10. #10
    Here's what I ended up using.

    Following Moon's suggestion, I just morphed a generic control to emulate a 'windowreferencecontrol'. I may be missing bits, but it serves my needs. I added custom logic on my activate method which I've omitted for brevity, fits in a script tag within a generic control.

    Code:
    local gTargetClass;
    local gTargetRecordName;
    local gIconNormal;
    local gIconPressed;
    
    
    function onInit()
    end
    
    function onClickRelease(button, x, y)
    	self.setIcon(gIconNormal,true); 
    	activate(); 
    	return true; 
    end
    
    function onClickDown(button, x, y)
    	self.setIcon(gIconPressed,true); 
    	return true; 
    end
    
    function onHover(state)
    	if state == false then
    		self.setIcon(gIconNormal,true); 
    	end
    end
    
    function setIcons(normal, pressed)
    	gIconNormal = normal;
    	gIconPressed = pressed; 
    	self.setIcon(gIconNormal,true); 
    end
    
    function setValue(class, recordname)
    	gTargetClass = class;
    	gTargetRecordName = recordname; 
    	onValueChanged(); 
    end
    
    function onValueChanged()
    end
    
    function isEmpty()
    	return gTargetClass == nil; 
    end
    
    function getTargetDatabaseNode()
    	return DB.findNode(gTargetRecordName); 
    end
    
    
    function activate()
    	local wnd = Interface.findWindow(gTargetClass,gTargetRecordName);
    	if wnd then
    		wnd.bringToFront(); 
    	else
    		wnd = Interface.openWindow(gTargetClass,gTargetRecordName); 
    	end
    	return true; 
    end

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
  •  
Starfinder Playlist

Log in

Log in