Flex 4:Capturing mouse events with spark.primitive.path objects - flex4

I am trying to capture mouse events whenever the mouse does something over top of a spark.primitive.path (the 'L' shape below).
Everything I have read states that I need to put the path inside of a Group object and attach mouse handlers to that. So the code would look something like this..
<s:Group left="10" right="10" top="10" bottom="10" mouseOver="...">
<s:Path data="M 100 300 L 200 50 L 275 50 L 250 150 L 300 150 L 300 300 Z">
<s:stroke>
<s:SolidColorStroke color="0x888888"/>
</s:stroke>
</s:Path>
</s:Group>
...and produces something like this on screen (please forgive the ascii art)
_____________________________
| |
| _______ |
| / / |
| / / |
| / / |
| / /_____ |
| / | |
| / | |
| /______________| |
| |
-----------------------------
This does almost work. The problem is the mouse events are fired based on dimensions of the Group object, not the Path. So, if you mouse over to the left of the path that still fires mouse events, because the Group is a box starting at 0,0 and ending at the bottom right side of the 'L'.
Any thoughts on how I can resolve this (or an alternate solution) are greatly appreciated.

If you use a SkinnableContainer instead of a Group, you will get the behavior you are looking for.

Try encapsulating in a Graphic object (Flex4). See there: http://blog.flexexamples.com/2010/03/22/creating-a-simple-image-map-in-flex-4/

Related

Shadows on windows with a bit depth of 32

In my reparenting window manager, I reparent windows to frames with the same bit depth:
let geom = self.conn.get_geometry(ev.window)?.reply()?;
let attr = self.conn.get_window_attributes(ev.window)?.reply()?;
let frame_win = self.conn.generate_id()?;
let win_aux = xproto::CreateWindowAux::new()
.event_mask(
xproto::EventMask::EXPOSURE
| xproto::EventMask::SUBSTRUCTURE_REDIRECT
| xproto::EventMask::SUBSTRUCTURE_NOTIFY
| xproto::EventMask::BUTTON_PRESS
| xproto::EventMask::BUTTON_RELEASE
| xproto::EventMask::POINTER_MOTION
| xproto::EventMask::ENTER_WINDOW
| xproto::EventMask::PROPERTY_CHANGE,
)
.background_pixel(self.config.background_pixel)
.border_pixel(self.config.border_pixel)
.colormap(attr.colormap);
self.conn.create_window(
geom.depth,
frame_win,
screen.root,
geom.x,
geom.y,
geom.width,
geom.height + self.config.title_height as u16,
self.config.border_width as u16,
xproto::WindowClass::INPUT_OUTPUT,
attr.visual,
&win_aux,
)?;
However, when the bit depth of the inside window and therefore the frame is 32, compositors do not draw shadows around the frame. If it has another depth like 24 they do. why would this happen?
It looks like xcompmgr just doesn't composite windows with a depth of 32. Picom and Compton work fine. Maybe there's some setting to change that; at any rate, there's nothing the wm can do about it.

Hypertreelist not firing when item selected

I am on a Windows machine, I am using WxPython Phoenix. I have a hypertreelist that should fire a function when an item is selected (or focused/clicked)...
import wx.lib.agw.hypertreelist as htl
self.apps_tree = htl.HyperTreeList(self, -1,
size=wx.Size(width, height),
style=wx.TR_NO_BUTTONS | wx.TR_FULL_ROW_HIGHLIGHT | wx.TR_SINGLE | wx.TR_HIDE_ROOT | wx.TR_NO_LINES,
agwStyle=wx.TR_FULL_ROW_HIGHLIGHT | wx.TR_HAS_VARIABLE_ROW_HEIGHT | wx.TR_NO_BUTTONS | wx.TR_NO_LINES | wx.TR_HIDE_ROOT)
self.apps_tree.Bind(wx.EVT_TREE_SEL_CHANGED, self.OnAppSelected)
I've tried to append the Bind on self (wx.Panel), I tried to use other events such as EVT_TREE_ITEM_HYPERLINK, EVT_TREE_ITEM_ACTIVATED but none worked. The code above works on Mac though...
The item not even gets colored... I have other elements on screen but as far as I can tell there is no overlaying...
For anyone having this issue...
I manage to make this work using self.Layout() after adding all elements on screen

Make arbitrary widget appear as a top-level window in GTK on X

In Windows, it is possible to say
CreateWindow("myclass",...,WS_CHILD,...);
or
CreateWindow("myclass",...,WS_OVERLAPPEDWINDOW,...);
It is also possible to switch appearance at will:
SetWindowLongPtr((HWND)handle,GWL_STYLE,style_1);
SetWindowPos((HWND)handle,HWND_TOP,0,0,0,0,SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED);
SetWindowLongPtr((HWND)handle,GWL_EXSTYLE,style_0);
SetWindowPos((HWND)handle,HWND_TOP,0,0,0,0,SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED);
if(style_1&WS_CHILD)
{
HWND owner=GetWindow((HWND)handle,GW_OWNER);
SetParent((HWND)handle,owner);
}
else
{SetParent((HWND)handle,NULL);}
It seems to me that most other GUI toolkits make a clear distinction between top-level windows and other widgets. The question is if and how it is possible to implement similar behavior in GTK on X
There is a GTK_WINDOW_TOPLEVEL and GTK_WINDOW_POPUP - unless you know what you do use the first. Also RTM https://developer.gnome.org/gtk3/stable/gtk3-Standard-Enumerations.html#GtkWindowType
You need to create a GtkWindow or GtkMainWindow and then add your desired widget x via gtk_container_add to the window you created.

How to preserve scroll position when calling SetWindowText on Edit control

I create an edit control with:
HWND hwnd = CreateWindow( "EDIT", tabText.c_str(), WS_CHILD | WS_VSCROLL | ES_LEFT | ES_MULTILINE | ES_AUTOVSCROLL, ...)
Then I update its contents by calling SetWindowText(...). But every time the update completes the scroll is set to the beginning. I need to make it preserve its position.
I write to this control a log. That means that the text string is getting bigger.
I tried to get scroll info before calling SetWindowText() and set scroll info after the call. This results in a blinking of the control.
How can I preserve scroll position and view the text while it is updated?

How to add image in CTreeCtrl list in MFC

I am trying to add Image before the text in CTreeList control but it is not coming up, But what i observed is the the node name is started after some space , like it is leaving the space for bitmap , but image is not showing up.. here is the code snap:-
CImageList m_ImageList;
CBitmap m_Bitmap1;
m_ImageList.Create(16,16,ILC_COLOR32,1,1);
m_Bitmap1.LoadBitmap(IDB_BITMAP1);
m_ImageList.Add(&m_Bitmap1, RGB(0,0,0));
TreeSoft->Create(WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP |
TVS_HASLINES | TVS_HASBUTTONS | TVS_LINESATROOT |
TVS_SINGLEEXPAND | TVS_SHOWSELALWAYS |
TVS_TRACKSELECT,
CRect(10, 10, 200, 240), this, 0x1221);
TreeSoft->SetImageList(&m_ImageList, TVSIL_NORMAL);
hTree = TreeSoft->InsertItem( L"Software Production",0,0, TVI_ROOT);
hCompany = TreeSoft->InsertItem(L"Microsoft",0,0, hTree);
Pls tell me what i am missing here...
Now you just need to set the image for the newly created branch:
TreeSoft->SetItemImage(hTree , 0, 0); // I think it starts from 0 (if it does not show try 1)
Just for testing purposes.
Create an icon with 16-bit color palette.
Instead of ILC_COLOR32 use ILC_COLOR.
And instead of RGB(0,0,0) use (COLORREF)0xFFFFFF
I have exact the same code except the smaller color palette and it works.
If this works you can try with the bigger palette.

Resources