WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   frame blocks keyboard input (https://www.wowinterface.com/forums/showthread.php?t=57914)

blocker147 04-06-20 07:57 AM

frame blocks keyboard input
 
How not to block keyboard bindings when my Frame is shown? For example I want to use WSAD and move with my hero when Frame is shown but I cant.

Lybrial 04-06-20 08:45 AM

A frame usually does not block keyboard inputs.

Lua Code:
  1. local frame = CreateFrame("Frame", "SomeFrame" _G.UIParent);
  2. frame:SetSize(50, 50);
  3. frame:SetPoint("CENTER");
  4. frame:SetBackdrop({bgFile = "Interface/Tooltips/UI-Tooltip-Background",
  5.                                             edgeFile = "Interface/Tooltips/UI-Tooltip-Border",
  6.                                             tile = true, tileSize = 16, edgeSize = 16,
  7.                                             insets = { left = 4, right = 4, top = 4, bottom = 4 }});

Above code creates a 50 x 50 frame in the middle of the screen.
It wont block any keyboard inputs.

blocker147 04-06-20 09:02 AM

But why my frame could block keyboard input? It depends on the frame size? I found method EnableKeyboard() and it is set to false. Which one frame method could block keyboard input? What should I look for?

Lybrial 04-06-20 10:50 AM

It would help if you post your code :)

blocker147 04-06-20 12:55 PM

4 Attachment(s)
Quote:

Originally Posted by Lybrial (Post 335565)
It would help if you post your code :)

Actually too much code for posting ~300 lines. I will show structure and screens.
And the question is what can block keyboard inputs?
Attachment 9435
Attachment 9434
Attachment 9436
Attachment 9437

JDoubleU00 04-07-20 02:39 PM

If you put your code within tags, then 300 lines are not too much. That creates a scrollable box.

Fizzlemizz 04-07-20 05:41 PM

If you have an EditBox (if that's what the second image is suggesting (ebKeyWord)) that could be automatically taking focus.

blocker147 04-08-20 07:11 AM

Quote:

Originally Posted by JDoubleU00 (Post 335576)
If you put your code within tags, then 300 lines are not too much. That creates a scrollable box.

my xml code only editbox:
Code:

<EditBox name="ebKeyWord" inherits="InputBoxTemplate" enableKeyboard="true" autoFocus="false">
        <Size x="115" y="32" />
        <Anchors>
                <Anchor point="TOPLEFT" x="120" y="-5" />
        </Anchors>
        <Scripts>
                <OnEnterPressed>
                        ebKeyWord_OnEnterPressed()
                </OnEnterPressed>
        </Scripts>
</EditBox>

my xml code (almost full):
Code:

<Ui xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.blizzard.com/wow/ui/">
        <Script file="Frame.lua" />
        <Frame name="MainFrame" movable="true" enableMouse="true">
                <Size x="600" y="425" />
                <Anchors>
                        <Anchor point="CENTER" x="0" />
                </Anchors>
                <Backdrop bgFile="Interface\DialogFrame\UI-DialogBox-Background-Dark.PNG" edgeFile="Interface\DialogFrame\UI-DialogBox-Border.PNG" tile="true">
                        <BackgroundInsets>
                                <AbsInset left="10" right="10" top="10" bottom="10" />
                        </BackgroundInsets>
                        <TileSize val="32" />
                        <EdgeSize val="32" />
                        <Color r="0" g="0" b="0" a="0.7" />
                </Backdrop>
                <Frames>
                        <Frame name="CloseWindowFrame">
                                <Size x="32" y="32" />
                                <Anchors>
                                        <Anchor point="TOPRIGHT" x="-4" y="-4" />
                                </Anchors>
                                <Backdrop bgFile="Interface\DialogFrame\UI-DialogBox-Corner.PNG" edgeFile="" />
                                <Frames>
                                        <Button name="btnCloseWindow" inherits="UIPanelCloseButton" parent="" text="X">
                                                <Size x="32" y="32" />
                                                <Anchors>
                                                        <Anchor point="TOPLEFT" x="4" y="4" />
                                                </Anchors>
                                                <Backdrop bgFile="" edgeFile="" />
                                                <Scripts>
                                                        <OnClick>
                                                                btnCloseWindow_OnClick()
                                                        </OnClick>
                                                </Scripts>
                                        </Button>
                                </Frames>
                        </Frame>
                        <Frame name="TitleFrame" parent="MainFrame">
                                <Size x="250" y="70" />
                                <Anchors>
                                        <Anchor point="TOP" x="0" y="10" />
                                </Anchors>
                                <Backdrop bgFile="Interface\DialogFrame\UI-DialogBox-Header.PNG" edgeFile="">
                                        <TileSize val="32" />
                                        <EdgeSize val="32" />
                                </Backdrop>
                                <Layers>
                                        <Layer level="OVERLAY">
                                                <FontString name="fsTitle" inherits="GameFontNormalLarge" text="Chat Filter">
                                                        <Size x="250" y="70" />
                                                        <Anchors>
                                                                <Anchor point="CENTER" y="12" />
                                                        </Anchors>
                                                </FontString>
                                        </Layer>
                                </Layers>
                        </Frame>
                        <ScrollFrame name="ScrollFrame1" inherits="UIPanelScrollFrameTemplate">
                                <Size x="550" y="256" />
                                <Anchors>
                                        <Anchor point="BOTTOM" x="-10" y="10" />
                                </Anchors>
                                <Backdrop bgFile="" edgeFile="">
                                        <TileSize val="32" />
                                        <EdgeSize val="32" />
                                </Backdrop>
                                <Frames>
                                        <Frame name="MessageBoxFrame">
                                                <Size x="550" y="256" />
                                                <Anchors>
                                                        <Anchor point="TOP" />
                                                </Anchors>
                                                <Backdrop bgFile="" edgeFile="">
                                                        <TileSize val="32" />
                                                        <EdgeSize val="32" />
                                                </Backdrop>
                                        </Frame>
                                </Frames>
                                <Scripts>
                                        <OnMouseWheel>
                                                ScrollFrame1_OnMouseWheel()
                                        </OnMouseWheel>
                                </Scripts>
                        </ScrollFrame>
                        <Frame name="ConfigFrame" parent="MainFrame">
                                <Size x="550" y="100" />
                                <Anchors>
                                        <Anchor point="TOP" x="-10" y="-30" />
                                </Anchors>
                                <Backdrop bgFile="" edgeFile="Interface\Tooltips\UI-Tooltip-Border.PNG">
                                        <BackgroundInsets left="4" right="4" top="4" bottom="4" />
                                        <TileSize val="32" />
                                        <EdgeSize val="16" />
                                        <Color r="1" g="1" b="1" />
                                        <BorderColor r="0.706" g="0.706" b="0.706" />
                                </Backdrop>
                                <Layers>
                                        <Layer level="OVERLAY">
                                                <FontString name="fsAddKeyWord" inherits="GameFontNormal" text="Enter Keyword:">
                                                        <Size x="115" y="32" />
                                                        <Anchors>
                                                                <Anchor point="TOPLEFT" x="5" y="-5" />
                                                        </Anchors>
                                                </FontString>
                                                <FontString name="fsFoundKeyInMessage" inherits="GameFontNormalLarge" text="" justifyH="LEFT">
                                                        <Size x="358" y="32" />
                                                        <Anchors>
                                                                <Anchor point="LEFT" x="47" y="-5" />
                                                        </Anchors>
                                                </FontString>
                                                <FontString name="fsFindInRaidNames" inherits="GameFontHighlight" text="Find in raid names ?" justifyH="LEFT">
                                                        <Size x="125" y="32" />
                                                        <Anchors>
                                                                <Anchor point="TOPRIGHT" x="-25" y="-5" />
                                                        </Anchors>
                                                </FontString>
                                        </Layer>
                                </Layers>
                                <Frames>
                                        <Button name="btnAddKeyWord" inherits="UIPanelButtonTemplate" ignoreParentAlpha="true" text="Add Keyword">
                                                <Size x="100" y="25" />
                                                <Anchors>
                                                        <Anchor point="TOPLEFT" x="240" y="-10" />
                                                </Anchors>
                                                <Scripts>
                                                        <OnClick>
                                                                btnAddKeyWord_OnClick()
                                                        </OnClick>
                                                </Scripts>
                                        </Button>
                                        <EditBox name="ebKeyWord" inherits="InputBoxTemplate" enableKeyboard="true" autoFocus="false">
                                                <Size x="115" y="32" />
                                                <Anchors>
                                                        <Anchor point="TOPLEFT" x="120" y="-5" />
                                                </Anchors>
                                                <Scripts>
                                                        <OnEnterPressed>
                                                                ebKeyWord_OnEnterPressed()
                                                        </OnEnterPressed>
                                                </Scripts>
                                        </EditBox>
                                        <CheckButton name="cbFindInRaidNames" inherits="UICheckButtonTemplate" text="CheckButton1">
                                                <Size x="32" y="32" />
                                                <Anchors>
                                                        <Anchor point="TOPRIGHT" x="-150" y="-5" />
                                                </Anchors>
                                                <Scripts>
                                                        <OnClick>
                                                                cbFindInRaidNames_OnClick()
                                                        </OnClick>
                                                </Scripts>
                                        </CheckButton>
                                        <Frame name="KeywordImageFrame">
                                                <Size x="24" y="24" />
                                                <Anchors>
                                                        <Anchor point="LEFT" x="10" y="-5" />
                                                </Anchors>
                                                <Backdrop bgFile="Interface\ICONS\INV_Misc_Key_12.PNG" edgeFile="">
                                                        <TileSize val="32" />
                                                        <EdgeSize val="32" />
                                                </Backdrop>
                                        </Frame>
                                </Frames>
                        </Frame>
                </Frames>
                <Scripts>
                        <OnLoad>
                                MainFrame_OnLoad()
                        </OnLoad>
                        <OnKeyDown>
                                MainFrame_OnKeyDown()
                        </OnKeyDown>
                        <OnDragStart>
                                MainFrame_OnDragStart()
                        </OnDragStart>
                        <OnDragStop>
                                MainFrame_OnDragStop()
                        </OnDragStop>
                        <OnEvent>
                                MainFrame_OnEvent()
                        </OnEvent>
                        <OnShow>
                                MainFrame_OnShow()
                        </OnShow>
                        <OnHide>
                                MainFrame_OnHide()
                        </OnHide>
                </Scripts>
        </Frame>
</Ui>


Fizzlemizz 04-08-20 09:20 AM

https://wow.gamepedia.com/UIHANDLER_OnKeyDown

blocker147 04-08-20 10:15 AM

Quote:

Originally Posted by Fizzlemizz (Post 335581)

Cool! This thing blocked my keyboard. But the next question is how to close MainFrame when escape is pressed? I tried to disable keyboard when key up or key down but this wont work.
Maybe I need to create event OnKeyDown on my button rather than on MainFrame?
Code:

function MainFrame_OnKeyDown()
        if arg1 == "ESCAPE" then MainFrame:Hide() end
end
function MainFrame_OnKeyUp()
        MainFrame:EnableKeyboard(false)
end


Fizzlemizz 04-08-20 10:43 AM

Frame names are global so MainFrame is not a good name. You should also add $parent to subframe names (and/or use the parentKey attribute).

Code:

<Frame name="blocker147MainFrame" movable="true" enableMouse="true">
...
    <OnLoad>
        tinsert(UISpecialFrames, "blocker147MainFrame")
    </OnLoad>
</Frame>



All times are GMT -6. The time now is 07:14 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI