This App is No Longer Maintained. Visit the Replacement at StrokesPlus.net

StrokesPlus Forum
                       
StrokesPlus Forum
Home | Profile | Active Topics
Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Feature Updates
 New Features
 [ADDED] acCreatePopupMenu
 Forum Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

Rob

USA
2615 Posts

Posted - 11/02/2013 :  18:50:22  Show Profile  Visit Rob's Homepage
Added in 2.7.5:

acCreatePopupMenu(x, y, items, delim, function)

This function lets you display a custom popup menu via a delimited (specified in delim parameter) list of menu items (items parameter); "-" will create a menu separator. You define a function under Global Lua which will be called by S+ after a menu item is selected. The function must only accept a single parameter, which will always be a number.

Menu separators are skipped in terms of getting assigned an ID. Meaning, in the following example, the only potential values for id passed into popupMenu are 1, 2, 3, or 4.

Action script:
local swnd = acFindWindow("STROKESPLUS",nil)
foregroundWindow = acGetForegroundWindow() -- Save the current foreground window for later
acActivateWindow(swnd) --Bring S+ to the foreground
acDelay(100)
acPostMessage(swnd, 0x0000, 0, 0) 
acDelay(100)
acCreatePopupMenu(gex, gey, "New Tab,Close Tab,-,Show ID,-,Close Menu", ",", "popupMenu")


Global Lua:
foregroundWindow = 0 --Important to declare without local keyword

function popupMenu(id)
	acActivateWindow(foregroundWindow) --Reset focus back to the original foreground app
	foregroundWindow = 0
	if id == 1 then
		acSendKeys("^t")
	elseif id == 2 then
		acSendKeys("^w")
	elseif id == 3 then
		acDelay(200) 
		acMessageBox("id: "..id)
	else
		--Do nothing, for the Close Menu item
	end
end

Note that you can make as many separate Global Lua functions as you'd like to support many different menus, assuming they all have different names. All you have to do is specify the proper function name in your action's call to acCreatePopupMenu.

You can also replace the code the gets the current foreground window if you'd like to bring the focus to the window below where the gesture began, e.g.
foregroundWindow = acGetOwnerWindowByPoint(gsx, gsy)

  Previous Topic Topic Next Topic  
 Forum Locked
 Printer Friendly
Jump To:
StrokesPlus Forum © 2011-2018 Rob Yapchanyk Go To Top Of Page
Snitz Forums 2000