DICE PACKS BUNDLE
  1. #1

    onHotKeyActivated problem

    I have two problems with this function.

    Problem 1. It seems the documentation mentions it twice by mistake here.

    onHotKeyActivated

    handler function onHotKeyActivated( dragdata )

    The functions registered on this handler will be called whenever a hot key is pressed.

    Parameters
    dragdata (dragdata)
    A dragdata object containing the state of values connected to the depressed hot key.

    onHotKeyDrop

    handler function onHotKeyDrop( dragdata )

    The functions registered on this handler will be called whenever an object is dropped on the hot key bar.

    Parameters
    dragdata (dragdata)
    A dragdata object containing the state of values connected to the mouse cursor as part of a drag and drop operation.

    onHotkeyActivated

    handler function onHotkeyActivated( draginfo )

    The functions registered on this handler will be called whenever a hot key bar slot is activated. This allows the processing of custom drag types and context specific special operation.

    Parameters
    draginfo (dragdata)
    The dragdata object representing the contents of the activated hot key bar slot
    The first entry references when a hotkey is pressed and the second when a slot is activated. They also pass two different types of data (dragdata & draginfo).

    Problem 2. I have a sample ext that I wrote using the above functions:
    Code:
    function onInit()
        if ChatManager then
            --ChatManager.registerSlashHandler("/KeyDmp", KeyDmp);
    		print ("ETUtility Loaded")
        end
    end
    
    function onHotKeyActivated( myData )
    	print("ETUtility Hotkey Pressed")
    	print(myData)
    	ChatManager.addMessage(myData)
    	return true;
    end
    
    function onHotKeyDrop( myData )
    	print("ETUtility Hotkey Dropped")
    	print(myData)
    	ChatManager.addMessage(myData)
    	return true;
    end
    
    function onHotkeyActivated( myData )
    	print("ETUtility Hotkey Activated")
    	print(myData)
    	ChatManager.addMessage(myData)
    	return true;
    end
    I know that the ext is being loaded because the "ETUtility Loaded" message (from the onInit function) appears on the console. Whenever I use the hotkeys, nothing appears on the console.

    Is there something I am missing?
    'Build it and they will come'
    Universal Table Rolling Get it HERE
    FG2 Help Files Get it HERE
    Getting the Most Out of Notepad++ (FG2 & Lua spellcheck & Auto-Completion) Get it HERE
    Printing the contents of a table Get it HERE

  2. #2
    Zeus's Avatar
    Join Date
    Mar 2009
    Location
    Olympus
    Posts
    2,658
    Blog Entries
    2
    I think the mistake is in the duplicate naming, the first function should really be named as onHotKeyPressed() or similar.

    Anyhow, these I believe are Event handlers meaning to utilise you need to 'register' functions to handle the events or putting it another way, override the default event handlers with your own functions in onInit() e.g. something like:

    Code:
    function onInit()
        if ChatManager then
            ChatManager.registerSlashHandler("/KeyDmp", KeyDmp);
    	print ("ETUtility Loaded")
        end
    
        Interface.onHotKeyActivated = myonHotKeyActivated;
        Interface.onHotKeyDrop = myonHotKeyDrop;
        Interface.onHotkeyActivated = myonHotkeyActivated;
    
    end
    
    function myonHotKeyActivated( myData )
    	print("ETUtility Hotkey Pressed")
    	print(myData)
    	ChatManager.addMessage(myData)
    	return true;
    end
    
    function myonHotKeyDrop(myData)
    	print("ETUtility Hotkey Dropped")
    	print(myData)
    	ChatManager.addMessage(myData)
    	return true;
    end
    
    function myonHotkeyActivated(myData)
    	print("ETUtility Hotkey Activated")
    	print(myData)
    	ChatManager.addMessage(myData)
    	return true;
    end
    Think that should work, although a word of warning, hotkeys can hold non-text content, you should therefore check for the data type of myData before using print() or the ChatManager.addMessage routines, this will avoid possible error conditions from arising .
    Last edited by Zeus; November 23rd, 2010 at 23:56.
    FG Project Development
    Next Project(s)*: Starfinder v1.2 Starship Combat

    Current Project:
    Starfinder v1.1 - Character Starships
    Completed Projects: Starfinder Ruleset v1.0, Starfinder Core Rulebook, Alien Archive, Paizo Pathfinder Official Theme, D&D 5E data updates
    * All fluid by nature and therefore subject to change.

  3. #3
    It did not like the use of:
    Interface.onHotKeyActivated = myonHotKeyActivated;
    Interface.onHotKeyDrop = myonHotKeyDrop;
    Interface.onHotkeyActivated = myonHotkeyActivated;
    It gave the following on each:
    Script Error: [string "scripts/ETUtility.lua"]:7: attempt to set a value for an invalid handler 'onHotKeyActivated'
    'Build it and they will come'
    Universal Table Rolling Get it HERE
    FG2 Help Files Get it HERE
    Getting the Most Out of Notepad++ (FG2 & Lua spellcheck & Auto-Completion) Get it HERE
    Printing the contents of a table Get it HERE

  4. #4
    The handler options are: onHotkeyDrop and onHotkeyActivated.

    Make sure you have the right capitalization.

    Cheers,
    JPG

  5. #5
    That worked... I will make sure the capitalization is corrected in the helpfiles I am creating.
    'Build it and they will come'
    Universal Table Rolling Get it HERE
    FG2 Help Files Get it HERE
    Getting the Most Out of Notepad++ (FG2 & Lua spellcheck & Auto-Completion) Get it HERE
    Printing the contents of a table Get it HERE

  6. #6

    Join Date
    Apr 2008
    Location
    Virginia Beach
    Posts
    3,096
    Can we get the documentation fixed for the duplicate functions?

  7. #7
    I let them know about it already. In the meantime, I have fixed it in my Unified Help Files.

    I actually found about 5 errors so far.

    https://www.fantasygrounds.com/forum...ad.php?t=13849
    'Build it and they will come'
    Universal Table Rolling Get it HERE
    FG2 Help Files Get it HERE
    Getting the Most Out of Notepad++ (FG2 & Lua spellcheck & Auto-Completion) Get it HERE
    Printing the contents of a table Get it HERE

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
  •  
FG Spreadshirt Swag

Log in

Log in