Trouble Passing Input Through Parent WIndows to Children

For help with general CEGUI usage:
- Questions about the usage of CEGUI and its features, if not explained in the documentation.
- Problems with the CMAKE configuration or problems occuring during the build process/compilation.
- Errors or unexpected behaviour.

Moderators: CEGUI MVP, CEGUI Team

kabbotta
Just popping in
Just popping in
Posts: 11
Joined: Tue Mar 10, 2015 01:47

Trouble Passing Input Through Parent WIndows to Children

Postby kabbotta » Thu Jul 02, 2015 02:20

I have the input working just fine for any "top-level" widget in my CEGUI interface, but I can't seem to get the input events to pass through down to children windows.

In my layout, I've added the MousePassThroughEnabled true value to each of the parent windows that contain the list I want to affect, but it doesn't seem to help. I've written my own looknfeel and scheme files, so is there something I'm missing when building the widgets that prepares them to receive input from their parent?

Here is a link to the project and the location of all my xml files: https://github.com/kabbotta/Last-Ditch/ ... dist/media

User avatar
Ident
CEGUI Team
Posts: 1998
Joined: Sat Oct 31, 2009 13:57
Location: Austria

Re: Trouble Passing Input Through Parent WIndows to Children

Postby Ident » Thu Jul 02, 2015 21:21

MousePassThroughEnabled is for siblings, not for children. If a window ignores the input, such as it happens with MousePassThroughEnabled , then the input won't be propagated to children at all.

I didn't download your datafiles because of time constraints, maybe someone else can and can then tell you what to do. I can help you if you show a screenshot or explain your layout in detail. Also a question that I m asking myself first here is: Why can't you use the regular input handling without any special property? Like, what makes your setup different?

Also feel free to post any layouts etc in Code tags., especially the relevant bits.
CrazyEddie: "I don't like GUIs"

kabbotta
Just popping in
Just popping in
Posts: 11
Joined: Tue Mar 10, 2015 01:47

Re: Trouble Passing Input Through Parent WIndows to Children

Postby kabbotta » Thu Jul 02, 2015 22:01

Sorry, I'll try to be more specific. Regular input handling is what I tried first and it wasn't responding. If I add my MultiColumnList directly to the root, then it responds perfectly. I can use all of the scrollbars and select items. But if I add it as a child of a series of container windows, then it doesn't seem to receive the input. I also found "DistributeCapturedInputs" property, but setting that to true doesn't seem to help either.

Here is the relevant part of my layout:

Code: Select all

<?xml version="1.0" ?>
<GUILayout version="4">
  <Window type="DefaultWindow" name="Root">
 
    <!-- Receives input correctly when declared this way -->
    <Window type="LastDitch/List" name="ItemList">
      <Property name="Position" value="{{.4, 0}, {.12, 0}}"/>
      <Property name="Size" value="{{.49, 0}, {.76, 0}}"/>
    </Window>
    ...
    <Window type="LastDitch/Frame" name="MenuWindow">

      <Window type="LastDitch/Container" name="InventoryContainer">

        <Window type="LastDitch/Label" name="InventoryLabel">
          <Property name="Position" value="{{.03, 0}, {.1, 0}}"/>
          <Property name="Size" value="{{0, 260}, {0, 26}}"/>
          <Property name="Text" value="Inventory"/>
          <Property name="Font" value="Jura-Medium-14"/>
       </Window>

       <!-- Does not receive input when declared here -->
       <!-- <Window type="LastDitch/List" name="ItemList"> -->
       <!--   <Property name="Position" value="{{.4, 0}, {.12, 0}}"/> -->
       <!--   <Property name="Size" value="{{.49, 0}, {.76, 0}}"/> -->
       <!-- </Window> -->
       ...


This works, but the exact same List definition placed in the commented out section doesn't work. Here is the snippet where I set the list up in code:

Code: Select all

// Does work
MultiColumnList* item_list =
  static_cast<MultiColumnList*>(
    root->getChild("ItemList"));
   
// Doesn't work
// inventory_container = root->getChild("MenuWindow/InventoryContainer");

// MultiColumnList* item_list =
//   static_cast<MultiColumnList*>(
//     inventory_container->getChild("ItemList"));

item_list->setSelectionMode(MultiColumnList::RowSingle);

ListboxTextItem* list_item;

item_list->addColumn("Item", 0, UDim(.6, 0));
item_list->addColumn("Weight", 1, UDim(.12, 0));
item_list->addColumn("Value", 2, UDim(.14, 0));
item_list->addColumn("Quantity", 3, UDim(.14, 0));

item_list->addRow();
list_item = new ListboxTextItem("Overgrowth 1", 101);
list_item->setSelectionBrushImage("LastDitch/ListSelectionBrush");
item_list->setItem(list_item, 0, 0);


I should say that it does display correctly, but it just doesn't receive any input events when placed as a deeper child in the layout. Thanks, your quick responses on this forum are appreciated.

User avatar
Ident
CEGUI Team
Posts: 1998
Joined: Sat Oct 31, 2009 13:57
Location: Austria

Re: Trouble Passing Input Through Parent WIndows to Children

Postby Ident » Thu Jul 02, 2015 22:17

Can you post the scheme too? You use non-standard names for your widgets so I can only guess what the issue is.

Aside from that I see no obvious issues so far.

I can btw definitely help you faster if you would manage to reconstruct the issue in the SampleBrowser (best with stock datafiles, such as Taharezlook which has a MLC) in a minimal setup for example by modifying the HelloWorld.cpp and posting the code here. If this problem persists there I will be able to debug it fast and find out what is wrong.
CrazyEddie: "I don't like GUIs"

kabbotta
Just popping in
Just popping in
Posts: 11
Joined: Tue Mar 10, 2015 01:47

Re: Trouble Passing Input Through Parent WIndows to Children

Postby kabbotta » Thu Jul 02, 2015 23:03

I'll see if I can work up something with the SamplerBrowser later, but I just quickly tried to swap out all of my custom elements with the corresponding TaharezLook elements and I still get the problem.

I loaded up the default TaharezLook using createFromFile and then used a layout like this:

Code: Select all

<?xml version="1.0" ?>
<GUILayout version="4">
  <Window type="DefaultWindow" name="Root">
    <Window type="TaharezLook/FrameWindow" name="MenuWindow">
      <Window type="TaharezLook/MultiColumnList" name="ItemList">
        <Property name="Position" value="{{.4, 0}, {.12, 0}}"/>
        <Property name="Size" value="{{.49, 0}, {.76, 0}}"/>
      </Window>


I can grab the FrameWindow and drag it around just fine, but the MultiColumnList still doesn't receive any input. And it works just fine if I move it up one level to reside under the DefaultWindow. It's like the DefaultWindow will dispatch the input events, but anything below it won't. My custom widgets are basically just simplified versions of the TaharezLook widgets.

User avatar
Ident
CEGUI Team
Posts: 1998
Joined: Sat Oct 31, 2009 13:57
Location: Austria

Re: Trouble Passing Input Through Parent WIndows to Children

Postby Ident » Thu Jul 02, 2015 23:27

What CEGUI version are you using?
Based on the layout you sent I will try this out tomorrow, it got kinda late here already
CrazyEddie: "I don't like GUIs"

kabbotta
Just popping in
Just popping in
Posts: 11
Joined: Tue Mar 10, 2015 01:47

Re: Trouble Passing Input Through Parent WIndows to Children

Postby kabbotta » Thu Jul 02, 2015 23:59

0.8.4 built directly from the repo. Thanks.

User avatar
Ident
CEGUI Team
Posts: 1998
Joined: Sat Oct 31, 2009 13:57
Location: Austria

Re: Trouble Passing Input Through Parent WIndows to Children

Postby Ident » Fri Jul 03, 2015 09:18

Tried it out in SampleBrowser. Works fine. I can click on columns, move the scrollbar, size the width of columns, change sorting etc etc.

layout:

Code: Select all

<?xml version="1.0" ?>
<GUILayout version="4">
  <Window type="DefaultWindow" name="Root">
    <Window type="TaharezLook/FrameWindow" name="MenuWindow">
      <Window type="TaharezLook/MultiColumnList" name="ItemList">
        <Property name="Position" value="{{.4, 0}, {.12, 0}}"/>
        <Property name="Size" value="{{.49, 0}, {.76, 0}}"/>
      </Window>
    </Window>
  </Window>
</GUILayout>



Altered HelloWorld.cpp:

Code: Select all

/***********************************************************************
    created:    11/8/2012
    author:     Lukas E Meindl
*************************************************************************/
/***************************************************************************
 *   Copyright (C) 2004 - 2012 Paul D Turner & The CEGUI Development Team
 *
 *   Permission is hereby granted, free of charge, to any person obtaining
 *   a copy of this software and associated documentation files (the
 *   "Software"), to deal in the Software without restriction, including
 *   without limitation the rights to use, copy, modify, merge, publish,
 *   distribute, sublicense, and/or sell copies of the Software, and to
 *   permit persons to whom the Software is furnished to do so, subject to
 *   the following conditions:
 *
 *   The above copyright notice and this permission notice shall be
 *   included in all copies or substantial portions of the Software.
 *
 *   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 *   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 *   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 *   IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
 *   OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
 *   ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 *   OTHER DEALINGS IN THE SOFTWARE.
 ***************************************************************************/
#include "HelloWorld.h"
#include "CEGUI/CEGUI.h"

#include <iostream>


/*************************************************************************
    Sample specific initialisation goes here.
*************************************************************************/
bool HelloWorldDemo::initialise(CEGUI::GUIContext* guiContext)
{
    using namespace CEGUI;

     d_usedFiles = CEGUI::String(__FILE__);

    // CEGUI relies on various systems being set-up, so this is what we do
    // here first.
    //
    // The first thing to do is load a CEGUI 'scheme' this is basically a file
    // that groups all the required resources and definitions for a particular
    // skin so they can be loaded / initialised easily
    //
    // So, we use the SchemeManager singleton to load in a scheme that loads the
    // imagery and registers widgets for the TaharezLook skin.  This scheme also
    // loads in a font that gets used as the system default.
    SchemeManager::getSingleton().createFromFile("TaharezLook.scheme");

    // The next thing we do is to set a default mouse cursor image.  This is
    // not strictly essential, although it is nice to always have a visible
    // cursor if a window or widget does not explicitly set one of its own.
    //
    // The TaharezLook Imageset contains an Image named "MouseArrow" which is
    // the ideal thing to have as a defult mouse cursor image.
    guiContext->getMouseCursor().setDefaultImage("TaharezLook/MouseArrow");

    // Now the system is initialised, we can actually create some UI elements, for
    // this first example, a full-screen 'root' window is set as the active GUI
    // sheet, and then a simple frame window will be created and attached to it.

    // All windows and widgets are created via the WindowManager singleton.
    WindowManager& winMgr = WindowManager::getSingleton();

    // Here we create a "DefaultWindow".  This is a native type, that is, it does
    // not have to be loaded via a scheme, it is always available.  One common use
    // for the DefaultWindow is as a generic container for other windows.  Its
    // size defaults to 1.0f x 1.0f using the Relative metrics mode, which means
    // when it is set as the root GUI sheet window, it will cover the entire display.
    // The DefaultWindow does not perform any rendering of its own, so is invisible.
    //
    // Create a DefaultWindow called 'Root'.


    CEGUI::Window* root = WindowManager::getSingleton().loadLayoutFromFile("kabotta.layout");
    CEGUI::MultiColumnList* item_list = static_cast<MultiColumnList*>(root->getChild("MenuWindow/ItemList"));
    item_list->setSelectionMode(MultiColumnList::RowSingle);

    ListboxTextItem* list_item;

    item_list->addColumn("Item", 0, UDim(.6, 0));
    item_list->addColumn("Weight", 1, UDim(.12, 0));
    item_list->addColumn("Value", 2, UDim(.14, 0));
    item_list->addColumn("Quantity", 3, UDim(.14, 0));

    item_list->addRow();
    list_item = new ListboxTextItem("Overgrowth 1", 101);/*
    list_item->setSelectionBrushImage("TaharezLook/Brush");*/

    // Set the root window as root of our GUI Context
    guiContext->setRootWindow(root);




    // return true so that the samples framework knows that initialisation was a
    // success, and that it should now run the sample.
    return true;
}


/*************************************************************************
    Cleans up resources allocated in the initialiseSample call.
*************************************************************************/
void HelloWorldDemo::deinitialise()
{
}

bool HelloWorldDemo::handleHelloWorldClicked(const CEGUI::EventArgs& args)
{
    std::cout << "Hello World!" << std::endl;

    return false;
}

/*************************************************************************
    Define the module function that returns an instance of the sample
*************************************************************************/
extern "C" SAMPLE_EXPORT Sample& getSampleInstance()
{
    static HelloWorldDemo sample;
    return sample;
}



Please try it out yourself and tell me if it works for you in the SampleBrowser!

I conclude that the issue is probably related to how you inject inputs or to some other misconfiguration.
CrazyEddie: "I don't like GUIs"

kabbotta
Just popping in
Just popping in
Posts: 11
Joined: Tue Mar 10, 2015 01:47

Re: Trouble Passing Input Through Parent WIndows to Children

Postby kabbotta » Fri Jul 03, 2015 21:51

Thanks to your assistance, I think I've finally discovered what was causing the problem, but I don't understand what the problem is.

In my layout, I had the "InventoryContainer" widget that was holding all of the widgets for the inventory menu, and then I also had further container widgets to hold things like the equipment menu widgets. The input begins working only when I remove all of the sibling containers. It works when I only have this in the layout:

Code: Select all

   <Window type="DefaultWindow" name="Root">

      <Window type="LastDitch/Frame" name="MenuWindow">
         <Property name="Visible" value="true"/>

         <Window type="LastDitch/Container" name="InventoryContainer">

            <Window type="LastDitch/Label" name="InventoryLabel">
               <Property name="Position" value="{{.03, 0}, {.1, 0}}"/>
               <Property name="Size" value="{{0, 260}, {0, 26}}"/>
               <Property name="Text" value="Inventory"/>
               <Property name="Font" value="Jura-Medium-14"/>
               <Property name="Visible" value="true"/>
            </Window>

            <Window type="LastDitch/List" name="ItemList">
               <Property name="Position" value="{{.4, 0}, {.12, 0}}"/>
               <Property name="Size" value="{{.49, 0}, {.76, 0}}"/>
               <Property name="Visible" value="true"/>
            </Window>
         </Window>


And it stops working when I add one more container:

Code: Select all

   <Window type="DefaultWindow" name="Root">

      <Window type="LastDitch/Frame" name="MenuWindow">
         <Property name="Visible" value="true"/>

         <Window type="LastDitch/Container" name="InventoryContainer">

            <Window type="LastDitch/Label" name="InventoryLabel">
               <Property name="Position" value="{{.03, 0}, {.1, 0}}"/>
               <Property name="Size" value="{{0, 260}, {0, 26}}"/>
               <Property name="Text" value="Inventory"/>
               <Property name="Font" value="Jura-Medium-14"/>
               <Property name="Visible" value="true"/>
            </Window>

            <Window type="LastDitch/List" name="ItemList">
               <Property name="Position" value="{{.4, 0}, {.12, 0}}"/>
               <Property name="Size" value="{{.49, 0}, {.76, 0}}"/>
               <Property name="Visible" value="true"/>
            </Window>
         </Window>

         <Window type="LastDitch/Container" name="EquipmentContainer">
            <Window type="LastDitch/Label" name="EquipmentLabel">
               <Property name="Position" value="{{.06, 0}, {.1, 0}}"/>
               <Property name="Size" value="{{0, 260}, {0, 26}}"/>
               <Property name="Text" value="Equipment"/>
               <Property name="Font" value="Jura-Medium-14"/>
               <Property name="Visible" value="false"/>
            </Window>
         </Window>

      </Window>


It only works when the "InventoryContainer" widget is placed as the last widget in the layout. So the input events must default to the last widget added in the layout. But then how do I tell the system to switch between active containers when I need the input to go to a different set of widgets at the sibling level?

User avatar
Ident
CEGUI Team
Posts: 1998
Joined: Sat Oct 31, 2009 13:57
Location: Austria

Re: Trouble Passing Input Through Parent WIndows to Children

Postby Ident » Sat Jul 04, 2015 23:57

Would be really great if you could edit the reconstruction attempt in HelloWorld.cpp from above so that i can actually debug the issue on my machine immediately. If you dont have time for that you will have to be patient for a bit, I am currently working hard on other CEGUi things.
CrazyEddie: "I don't like GUIs"

kabbotta
Just popping in
Just popping in
Posts: 11
Joined: Tue Mar 10, 2015 01:47

Re: Trouble Passing Input Through Parent WIndows to Children

Postby kabbotta » Tue Jul 07, 2015 07:11

Sorry, I had never built the SampleBrowser. I'm confused as to how I add a custom sample to the browser.

I've created a simple layout that mimics what I'm doing here:

Code: Select all

<?xml version="1.0" ?>
<GUILayout version="4">
   <Window type="DefaultWindow" name="Root">
      <Property name="MousePassThroughEnabled" value="true"/>

      <Window type="TaharezLook/FrameWindow" name="MenuWindow">
         <Property name="Visible" value="true"/>

         <!-- Equipment Window -->
         <Window type="DefaultWindow" name="EquipmentContainer">

            <Window type="TaharezLook/StaticText" name="EquipmentLabel">
               <Property name="Position" value="{{.06, 0}, {.1, 0}}"/>
               <Property name="Size" value="{{0, 260}, {0, 26}}"/>
               <Property name="Text" value="Equipment"/>
               <Property name="Visible" value="false"/>
            </Window>

         </Window>

         <!-- Inventory Window -->
         <Window type="DefaultWindow" name="InventoryContainer">

            <Window type="TaharezLook/StaticText" name="InventoryLabel">
               <Property name="Position" value="{{.03, 0}, {.1, 0}}"/>
               <Property name="Size" value="{{0, 260}, {0, 26}}"/>
               <Property name="Text" value="Inventory"/>
               <Property name="Visible" value="true"/>
            </Window>

            <Window type="TaharezLook/MultiColumnList" name="ItemList">
               <Property name="Position" value="{{.4, 0}, {.12, 0}}"/>
               <Property name="Size" value="{{.49, 0}, {.76, 0}}"/>
            </Window>

         </Window>

      </Window>

   </Window>

</GUILayout>


This works in my setup if the equipment window is first, but the ItemList no longer receives input if it is placed first. And I think only a single line needs to be added to HelloWorld.cpp to load it.

Code: Select all

winMgr->createFromFile("base_ui.layout");


There doesn't seem to be much about the SampleBrowser on the wiki.

User avatar
Ident
CEGUI Team
Posts: 1998
Joined: Sat Oct 31, 2009 13:57
Location: Austria

Re: Trouble Passing Input Through Parent WIndows to Children

Postby Ident » Thu Jul 09, 2015 23:11

Instead of creating a custom sample, why dont you edit the HelloWorld.cpp for example? I will look at your code example soon. Meanwhile you might wanna try out the SampleBrowser and edit one of the samples for repro.
CrazyEddie: "I don't like GUIs"

User avatar
Ident
CEGUI Team
Posts: 1998
Joined: Sat Oct 31, 2009 13:57
Location: Austria

Re: Trouble Passing Input Through Parent WIndows to Children

Postby Ident » Fri Aug 07, 2015 13:44

This is not a proper construction. As far as I am concerned everything I can test based on your reconstruction works 100% fine and as expected.

However I think i can guess your issue now. I can not be sure about it, since you didn't explain this more thoroughly in your example, but as far as I understand the problem you are having is because you have a FrameWindow ("MenuWindow") with two children that are DefaultWindows which exceed 100% of the size (this is a default and you didnt change it) and now you wonder why only one of them receives inputs when you click in the DefaultWindows' area. Well, basically you created two windows that cover the exact identical size. One of them is above the other due to the order of adding them (layout or code, acts the same way). Now if you click into space of one of those windows you will only hit whatever of these two windows is "higher" up in the hierarchy. Also the children which are visible because Defaultwindows are 100% transparent might not be clickable because the one defaultwindow containing other children might be covering the other defaultwindow with the child you want to click.

Clearly not a bug but a problem with your layout architecture. You can't really work around this with any properties because CEGUi can't know what you want to do when you click a window that is laid out like this. You might just wanna set your defaultwindows to a size that does not overlap.

Does this help? Was this the issue?
CrazyEddie: "I don't like GUIs"


Return to “Help”

Who is online

Users browsing this forum: No registered users and 16 guests