PDA

View Full Version : OSD Menu Timeout - how to detect ? - suggestion



AlCapone
June 29th, 2006, 02:52 AM
I would like the OSDMenu callback to also happen when menu times out.

taken from examples:


Menu = osd.Classes.AutoMenu:New ({AutoCallback = ExecuteResult})
local function ExecuteResult(Number, Text, Item)


ExecuteResult is never called if menu times out, I would like to request a callbac on Timeout, where Number = "0", or text="TimedOut" or item="TimedOut"

that would make it way easier to detect timeout.

AlCapone
June 29th, 2006, 01:10 PM
please take a look at this. ^

Promixis
June 29th, 2006, 06:26 PM
we can give the source to osd.lua to change if you want.

AlCapone
June 29th, 2006, 09:42 PM
yes, please ...I think i can modify it.

Ron
June 30th, 2006, 08:42 AM
Here it is.

birty
June 30th, 2006, 09:07 AM
try this. if the menu times out the callback is called with an empty item name and 0 as the item number

AlCapone
June 30th, 2006, 01:51 PM
Thank you.

I put the file into "C:\Program Files (x86)\Promixis\Girder\luascript\startup"
I do not get any callback on timeout - where did I do wrong ?

birty
June 30th, 2006, 01:52 PM
should be in luascript not luascript\startup

AlCapone
June 30th, 2006, 02:11 PM
yup that's were I had it the first time, then moved it to the wrong folder :)

anyway, it does not work even if in the right one.
in the callback function, I added a "print" , and it is not trigged at timeout, only on click.

The file you posted/i installed is 72 196 bytes

any further suggestion ? (i did not found the code that should do this, i havemost likely overseen it)

birty
June 30th, 2006, 11:21 PM
it seems that putting the osd.lua in the script directory no longer overrides the built in version

Rob H
June 30th, 2006, 11:48 PM
ISTR that you have to rename it to osd-work.lua

AlCapone
June 30th, 2006, 11:59 PM
renaming helped, now I am getting error:

"... Files (x86)\Promixis\Girder\\luascript\osd-work.lua:967: attempt to call method `IsOkay' (a nil value)"


I tried to comment out -- "if self.OSD:IsOkay() then ...."
but then I got other errors.

I am trying to make this work:




local MyMenu = {
Title="Ignition off",
[1]='Hibernate now',
[2]='Continue',
}



local function ExecuteResult(Number, Text, Item)


print ("Callback= ".. Text,Number,Item)
if Text == "" then
gir.TriggerEventEx("HibernationMenuTimeout", 18,0)
end


if type(Item) == 'string' then
-- a regular menu item was clicked.
--print "ending menu"
gir.TriggerEventEx("MenuEnded", 18,0)
gir.TriggerEvent(Text, 18,0)
end



if type(Item) == 'table' then

-- Figure out if it was a submenu or an extended item.
if not Item.Title then
-- alright this is an extended entry.
--gir.TriggerEvent(Item.EventString, Item.EventDevice,0)
else
-- Sub Menu Item Clicked

end

end

end



-- Recycle the menu
if not HibMenu then
HibMenu = osd.Classes.AutoMenu:New ({AutoCallback = ExecuteResult})
HibMenu:Initialize()
HibMenu.TimeOut=4000
HibMenu.MaxItems=5
end

if AutoMenu then
AutoMenu:Hide() -- Hide main menu, in case it is visible

end

-- Toggle visibility.
if not HibMenu.Visible then
HibMenu:Show (true, MyMenu)

else
HibMenu:Hide()
gir.TriggerEventEx("MenuEnded", 18, 0)
--print "test0"
end

Rob H
July 1st, 2006, 01:47 AM
Hmm... the osd doesn't seem to have an IsOkay method - something odd here!

We'll probably have to wait for Ron.

jmonier
July 1st, 2006, 06:47 AM
Try renaming it to osd-work.lua.

AlCapone
July 1st, 2006, 07:16 AM
Try renaming it to osd-work.lua.

done that several posts ago :)
now waiting for Ron to take a look at this .. will it help if I pray ? :)

jmonier
July 1st, 2006, 02:48 PM
done that several posts ago :)
now waiting for Ron to take a look at this .. will it help if I pray ? :)

Sorry, I missed that post. Did you try the version that Ron posted? That appears to be the same as the version that I've been working with (but without the timeout callback that you want). It works fine for me. If it also works for you (by trying a print statement) that would confirm a problem with the timeout modifications.

AlCapone
July 1st, 2006, 03:17 PM
Sorry, I missed that post. Did you try the version that Ron posted? That appears to be the same as the version that I've been working with (but without the timeout callback that you want). It works fine for me. If it also works for you (by trying a print statement) that would confirm a problem with the timeout modifications.

When I tried the file he posted, with the code I posted I've got errors before the OSD were displayed. (see above).

(The code I posted worked fine with latest Girder,but there is no timeout-callback)

AlCapone
July 2nd, 2006, 11:35 AM
please do not forget this.

AlCapone
July 3rd, 2006, 09:43 PM
bump - some days since last activity here..

Ron
July 4th, 2006, 08:41 AM
Sorry guys, I have no clue what is going on here. I posted the osd.lua somewhere else. Rob can you modifiy this to what is needed?

Rob H
July 4th, 2006, 08:58 AM
Of course the osd.lua is only for the osd extensions. I'd assumed that osd.IsOkay was a function in the osd object itself.

I'll probably break something if I try to modify osd.lua - perhaps birty should take a look first.

Ron
July 4th, 2006, 09:01 AM
hmmm. I have lost track of what the problem is here. Can someone sum it up?

Rob H
July 4th, 2006, 09:06 AM
hmm... hang on I was misreading the code, IsOkay is a method of self.OSD and it is indeed present.

Sounds as though something is overwriting self.OSD

I'll take a look at the code.

Rob H
July 4th, 2006, 09:09 AM
That's strange - the code in http://www.promixis.com/forums/showpost.php?p=100446&postcount=12 seems to work fine for me!

birty
July 4th, 2006, 09:12 AM
Its a bit strange but i have just redone the modifications on the original file and now it works

Ron
July 4th, 2006, 09:23 AM
Thanks guys, I'll wrap this into the next release.

AlCapone
July 4th, 2006, 11:37 AM
for now - I've already solved it using simpletimer, looking forward to next release.

Thank you all.