I would like to create a kind of desktop widget and want it to be very easy to style via HTML/CSS. I decided to use WebView
for this task.
I have got a borderless NSWindow
with a WebView
inside. I want to make it draggable using mouse (as any ordinary window can be dragged using its title, but by clicking anywhere inside my WebView
). Tried to subclass WebView
and override mouseDown
and mouseDragged
events, but that didn't work (for obvious reasons).
For sure, I can create a transparent view above WebView
to solve the problem, but I really want to find a better way. Does anybody know how to accomplish that?
The problem was solved by overriding the - (void)sendEvent:
method in the parent NSWindow
subclass, like this:
//Overriding mouse events
- (void)sendEvent:(NSEvent *)theEvent
{
if ([theEvent type] == NSLeftMouseDown)
{
[self mouseDown:theEvent];
}
else if ([theEvent type] == NSLeftMouseDragged)
{
[self mouseDragged:theEvent];
}
else
{
[super sendEvent:theEvent];
}
}
I guess this is the best solution.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With