English 中文(简体)
处理家长改变子女和主要角色的最佳方式?
原标题:Best way to deal with child to parent mouse and keyboard events in a gui?

For my Gui I want to use the following system: The way it works is that, if the widget under the mouse does not consume a mouse or kb event, it is passed to that widget s parent until it is consumed or the desktop is reached.

Just one thing puzzles me about it. Does that mean if a Button, for whatever reason has a Label as one of its children. If I click the label, would that not mean that my button, which is under the label would click (since a label does not consume the mouse), which is undesired in this case. Does that mean I d have to do if(mouseEvent.source == this){do button stuff} ?

增 编

最佳回答

如果标签是儿童植被,那么,如果是,标签将试图吃饭,失败(通常标签上没有手法),从而将事件退回到纽伦。

这样做最容易的方法是找到拉贝尔等级的子级,并超越处理功能(假设这在你的工具包中是可能的,它应当放在任何体面的工具包中)。 然后,你可以行使职能,把烟火点击,并将任何其他事件退回到纽伦。

Comparing pointers is probably a bad idea and is slightly dependent on the way the toolkit is implemented - for instance, it might deem the source as the button (because that s what it expects), not the label.

Though I find it highly strange that a Label is a widget in itself.....

问题回答

It looks like you need a special kind of "Label" which consumes mouse events. You should be able to create a customized widget (derived from Label) that consumes mouse events for this specific case.

如果Label的植被来自不能衍生/替代的第三方,那么你应将Label列入另一个植被: 单纯的植被消耗了 mo,只有一名孩子,即原来的拉贝尔。





相关问题
Undefined reference

I m getting this linker error. I know a way around it, but it s bugging me because another part of the project s linking fine and it s designed almost identically. First, I have namespace LCD. Then I ...

C++ Equivalent of Tidy

Is there an equivalent to tidy for HTML code for C++? I have searched on the internet, but I find nothing but C++ wrappers for tidy, etc... I think the keyword tidy is what has me hung up. I am ...

Template Classes in C++ ... a required skill set?

I m new to C++ and am wondering how much time I should invest in learning how to implement template classes. Are they widely used in industry, or is this something I should move through quickly?

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

typedef ing STL wstring

Why is it when i do the following i get errors when relating to with wchar_t? namespace Foo { typedef std::wstring String; } Now i declare all my strings as Foo::String through out the program, ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

Window iconification status via Xlib

Is it possible to check with the means of pure X11/Xlib only whether the given window is iconified/minimized, and, if it is, how?

热门标签