Ok, so i started messing around with this. Slowly.
I have a problem. In the GUI there is a top bar, that aare macros (hotkeys), but i can't manage to change what the F1, F2, ..., F12 do.
The code that i get from the plugin is this:
-- update the hotkeys
function update_hotkeys ()
-- To stop F1 opening the windows help dialog:
-- File -> Global Preferences -> General, "F1, F6 are macros"
data = msdp["HOTKEY"]
if data ~= nil then
hotkey = {}
index = 0
startpos = 1
max = 0
for i=1,string.len(data),1 do
if string.byte(data,i) == 9 or i == string.len(data) then
index = index + 1
hotkey[index] = string.sub(data, startpos, i)
startpos = i+1
end -- if
end -- for
if index == 3 then
hotkeys_name[tonumber(hotkey[1])] = hotkey[2]
hotkeys_action[tonumber(hotkey[1])] = hotkey[3]
Accelerator ("F"..hotkey[1], hotkey[3])
end -- if
end -- if
end -- update_hotkeys
function draw_hotkeys ()
for i=1,12,1 do
create_hotkey(i)
end -- for
end -- draw_hotkeys
function create_hotkey (hotkey_number)
win = "hotkey_window_"..hotkey_number
hotkey = "hotkey_"..hotkey_number
colour = ColourNameToRGB ("gold")
offset = 115 + (67*hotkey_number)
-- make a miniwindow under the text
check (WindowCreate (win, -- window ID
offset, -- left
2, -- top
65, -- width
41, -- depth
12, -- center it (ignored anyway)
2, -- draw underneath (1) + absolute location (2)
colour)) -- background colour
-- load the icon background image if possible
if hotkeys[hotkey_number] == nil or hotkeys[hotkey_number] == false then
button = "images/layout/button_background.png"
else -- true means the button has been pressed
button = "images/layout/button_background2.png"
end -- if
if WindowLoadImage (win, hotkey, GetInfo (66) .. button) == eOK then
check (WindowDrawImage (win, hotkey, 0, 0, 0, 0, 2)) -- draw it
end -- if
-- draw the 'F1' to 'F12' labels on the buttons
outlined_text (colour, win, "F"..tostring(hotkey_number), 6, 9, 23)
-- draw the label, if any
if hotkeys_name[hotkey_number] ~= nil then
outlined_text (colour, win, hotkeys_name[hotkey_number], 8, 9, 7)
end -- if
-- show the window
WindowShow (win, true)
-- create a hotspot over the timer
WindowAddHotspot(win, "hs_F"..tostring(hotkey_number), 0, 0, 65, 41, "", "", "hotkey_down", "hotkey_up", "hotkey_up", "F"..tostring(hotkey_number), 1, 0)
end -- create_hotkey
function update_hotkey (hotkey_number)
if hotkeys[hotkey_number] ~= nil then
win = "hotkey_window_"..hotkey_number
hotkey = "hotkey_"..hotkey_number
colour = ColourNameToRGB ("gold")
if hotkeys[hotkey_number] == false then
button = "images/layout/button_background.png"
else -- true means the button has been pressed
button = "images/layout/button_background2.png"
end -- if
if WindowLoadImage (win, hotkey, GetInfo (66) .. button) == eOK then
check (WindowDrawImage (win, hotkey, 0, 0, 0, 0, 2)) -- draw it
end -- if
-- draw the label, if any
if hotkeys_name[hotkey_number] ~= nil then
outlined_text (colour, win, hotkeys_name[hotkey_number], 8, 9, 7)
end -- if
-- draw the 'F1' to 'F12' labels on the buttons
outlined_text (colour, win, "F"..tostring(hotkey_number), 6, 9, 23)
end -- if
end -- update_hotkey
function outlined_text (colour, window, text, size, x, y)
outlineColour = colourBlack
-- write the information inside
WindowFont(window,'f','Times New Roman',size,1,0,0,0)
-- smear black text around the location to create an outline, so that it's clearer to read
WindowText(window,'f',text,x+1,y+1,0,0,outlineColour,0)
WindowText(window,'f',text,x+1,y,0,0,outlineColour,0)
WindowText(window,'f',text,x+1,y-1,0,0,outlineColour,0)
WindowText(window,'f',text,x,y+1,y,0,outlineColour,0)
WindowText(window,'f',text,x,y-1,y,0,outlineColour,0)
WindowText(window,'f',text,x-1,y+1,0,0,outlineColour,0)
WindowText(window,'f',text,x-1,y,0,0,outlineColour,0)
WindowText(window,'f',text,x-1,y-1,0,0,outlineColour,0)
-- display the text
WindowText(window,'f',text,x,y,0,0,colour,0)
end -- outlined_text
function get_hotkey_value (hotkey_string)
if hotkey_string == "hs_F1" then
return 1
elseif hotkey_string == "hs_F2" then
return 2
elseif hotkey_string == "hs_F3" then
return 3
elseif hotkey_string == "hs_F4" then
return 4
elseif hotkey_string == "hs_F5" then
return 5
elseif hotkey_string == "hs_F6" then
return 6
elseif hotkey_string == "hs_F7" then
return 7
elseif hotkey_string == "hs_F8" then
return 8
elseif hotkey_string == "hs_F9" then
return 9
elseif hotkey_string == "hs_F10" then
return 10
elseif hotkey_string == "hs_F11" then
return 11
elseif hotkey_string == "hs_F12" then
return 12
else
return 0
end -- if
end -- get_hotkey_value
function hotkey_down (flags, hotspot_id)
hotkey_number = get_hotkey_value (hotspot_id)
if hotkey_number ~= 0 then
hotkeys[hotkey_number] = true
update_hotkey (hotkey_number)
Redraw()
end -- if
return 0
end -- hotkey_down
function hotkey_up (flags, hotspot_id)
hotkey_number = get_hotkey_value (hotspot_id)
if hotkey_number ~= 0 then
hotkeys[hotkey_number] = false
update_hotkey (hotkey_number)
if hotkeys_action[hotkey_number] ~= nil then
Execute(hotkeys_action[hotkey_number])
Redraw()
else
Note("Hotkey not defined. Type 'hotkey' to set it.")
end -- if
end -- if
return 0
end -- hotkey_up
|