Patch for MMB on file upload

Germain Garand germain at ebooksfrance.org
Sun Oct 19 15:20:22 BST 2008


Le samedi 18 octobre 2008, Harri Porten a écrit :
> Hi!
>
> David reported that it is impossible to paste text into file upload
> elements with the middle-mouse button. Here is the result of my debugging
> session and a proposed fix.
>
> The file upload element is different from other form elements because
> KUrlRequester is a composite of two QWidgets (a KLineEdit and a
> KPushButton). I found out that a MMB click does not have a symmetric event
> delivery. The mouse press event goes to the embedded KLineEdit but the
> release goes to the KUrlRequester. Hence the past within
> QPushButton::mouseReleaseEvent() is not triggered.
>
> The asymmetry stems from RenderWidget::handleEvent() make the following
> exception for *left* mouse buttons on press
>
>       if ( button == Qt::LeftButton )
>          view()->setMouseEventsTarget( target );
>
> but unconditionally using the result on release:
>
>      target = view()->mouseEventsTarget();
>
> My naive fix (attached) consists of doing this for the left button only:
>
>      if ( button == Qt::LeftButton )
>          target = view()->mouseEventsTarget();

this looks mostly correct - the purpose of this code is to have mouse events 
be sent to the widget during all the time the left button is depressed, even 
when the mouse pointer is no longer above said widget. 

now I just verified this should work with other mouse buttons as well for 
perfect Qt emulation  (e.g. if you middle click in a normal Qt widget, 
maintain your middle click, move the pointer outside the widget, then 
release, the paste still happens in the original widget).

So the fix could simply be to remove the first condition and always 
setMouseEventsTarget...

Thank you for your fixes, the url requester should be in great shape now :)

Greetings,
Germain




More information about the kfm-devel mailing list