GenericMenu OnInputEvent is not firing!!!

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!

Moderator: GZDoom Developers

Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.

Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
Post Reply
User avatar
Nash
 
 
Posts: 17439
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia
Contact:

GenericMenu OnInputEvent is not firing!!!

Post by Nash »

Code: Select all

class MyMenu : GenericMenu
{
    override bool OnInputEvent(InputEvent ev)
    {
        if (ev.Type == InputEvent.Type_KeyDown)
        {
            Console.Printf("Pressed key: %d", ev.KeyScan);
            return true;
        }
        return Super.OnInputEvent(ev);
    }

    override void Drawer(void)
    {
        Screen.Dim(Color(0, 0, 0),
            0.4,
            -2 * CleanXFac,
            Screen.GetHeight() - ((SmallFont.GetHeight() * 2) * (CleanYFac + 2)),
            Screen.GetWidth() + (2 * CleanXFac),
            Screen.GetHeight());

        Screen.DrawText(SmallFont, Font.CR_WHITE,
            3 * CleanXFac, Screen.GetHeight() - ((SmallFont.GetHeight() * 2) * (CleanYFac + 1)),
            "My Awesome Menu!", DTA_CleanNoMove, true);

        Super.Drawer();
    }
}
 
I can NOT get the input event to fire at all. What am I doing wrong?
Attachments
MyMenu.pk3
(515 Bytes) Downloaded 23 times
User avatar
Nash
 
 
Posts: 17439
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia
Contact:

Re: GenericMenu OnInputEvent is not firing!!!

Post by Nash »

Is this a bug? I don't see anything wrong at all with this very short example.
_mental_
 
 
Posts: 3812
Joined: Sun Aug 07, 2011 4:32 am

Re: GenericMenu OnInputEvent is not firing!!!

Post by _mental_ »

OnInputEvent() is for in-game input only. For menu you need to override OnUIEvent() function.
User avatar
Nash
 
 
Posts: 17439
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia
Contact:

Re: GenericMenu OnInputEvent is not firing!!!

Post by Nash »

_mental_ wrote:OnInputEvent() is for in-game input only. For menu you need to override OnUIEvent() function.
If it's for in-game input, why is it defined as a virtual for the Menu class? Looks like ZDoom's own menus also use this, but it magically works there but not for me. :(
_mental_
 
 
Posts: 3812
Joined: Sun Aug 07, 2011 4:32 am

Re: GenericMenu OnInputEvent is not firing!!!

Post by _mental_ »

I meant that it's a special function to handle in-game like input. For example, to get a proper key for input customization. In this case it works because of menuactive set to a special value.
User avatar
Nash
 
 
Posts: 17439
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia
Contact:

Re: GenericMenu OnInputEvent is not firing!!!

Post by Nash »

_mental_ wrote:I meant that it's a special function to handle in-game like input. For example, to get a proper key for input customization. In this case it works because of menuactive set to a special value.
This is what I've been trying to do but I just cannot figure it out.

I want something to happen in my menu when the player presses whatever button is bound to, say "netevent EV_MySpecialFuction". I need this to work with any input - mouse, keyboard, gamepad, etc.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49067
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: GenericMenu OnInputEvent is not firing!!!

Post by Graf Zahl »

This function is for binding keys. You cannot really operate the menu with it.
Post Reply

Return to “Scripting”