Page 1 of 1

Clicking on non-transparent part of a window

Posted: Wed Nov 28, 2007 10:31
by genergabasa
Hello everyone, I'm new here in the forum. I just want to suggest that there should be a flag if a user wants to click the visible part of the window only, what I mean is that a window shouldn't be clicked when the user is clicking the one visible behind it. For example, I have a window with a StaticImage that looks like a ring and has a hole inside it and I was able to see another window behind it, lets say there's a flag behind it and I want to click it from the hole. Hope you'll make this a priority. Thanks!

Posted: Wed Nov 28, 2007 14:58
by Rackle
This is not the first time this has been asked. But it's not a trivial thing to code.

I think there are private functions to find the window at a given (x,y) coordinate. If a Z-ordered list was created then we could go through each and test the pixel colour until a non-transparent one is found. Hrm, maybe these pixel colours can be found by querying the widget's imagery.

It's been a long long time since I contributed anything. Maybe this could be it. And there's also that drag and drop stuff I was working on a long time ago.

Posted: Wed Nov 28, 2007 16:30
by scriptkid
Rackle wrote:Hrm, maybe these pixel colours can be found by querying the widget's imagery.


I did a quick search in the API but didn't find a way to actually look at pixels. If it's possible, then there is still an issue when an image is scaled, which should be taken care of.

Posted: Thu Nov 29, 2007 02:12
by genergabasa
Yeah, I also downloaded the source and tried to look for some code that might be able to help me manipulate the window click event but I didn't find anything helpful at all. I added a code to retrieve colours from a part of the window:

Code: Select all

bool Tool::mouseMoveHandler(const CEGUI::EventArgs& e)
{
   using namespace CEGUI;
   WindowManager& winMgr = WindowManager::getSingleton();
   Window* win = static_cast<const WindowEventArgs&>(e).window;
   const MouseEventArgs mouseEventArgs = static_cast<const MouseEventArgs&>(e);
   CEGUI::Vector2 localMousePos = CoordConverter::screenToWindow(*win, mouseEventArgs.position);
   UVector2 mouseMoveOffset(cegui_absdim(localMousePos.d_x), cegui_absdim(localMousePos.d_y));
   UVector2 mouseOffsetInWindow(cegui_absdim(mMousePosInWindow.d_x), cegui_absdim(mMousePosInWindow.d_y));
   win->setPosition(win->getPosition() + mouseMoveOffset - mouseOffsetInWindow);

   ColourRect crect = PropertyHelper::stringToColourRect(win->getProperty("ImageColours"));
   colour c = crect.getColourAtPoint(localMousePos.d_x, localMousePos.d_y);
   char text[50];
   sprintf_s(text, "RGB: %f:%f:%f", c.getRed(), c.getGreen(), c.getBlue());
   winMgr.getWindow("TextWindow")->setText(text);
   return true;
}

But it only returns the colors that will manipulate the orginal window's ARGB. :cry: