does this draggable textctrl work on Mac?

I don’t own a Mac, so would some kind Mac owner please test whether the attached 58 line program runs on (a recent) MacOS and allows you to drag the textCtrl smoothly around the screen? And, if it doesn’t allow dragging on Mac, why not? (It works on WinXP). (Written with wxPython 2.8.10.1, Python 2.5).

Thanks,
Che

draggable_text.py (1.88 KB)

It allows me to drag it in 2.8.10.1 (Python 2.6, OS 10.6.8), but it's
not very smooth - it seems to stop dragging of its own accord, perhaps
when I'm especially jerky with the mouse. It wasn't obvious how to
drag it either; I had to click on a narrow strip no more than 2 pixels
(if that) around the border.

With 2.9.3.1 and wxOSX-Cocoa it doesn't work at all, but lots of other
stuff doesn't either.

-Nat

···

On Mon, Feb 13, 2012 at 2:58 PM, C M <cmpython@gmail.com> wrote:

I don't own a Mac, so would some kind Mac owner please test whether the
attached 58 line program runs on (a recent) MacOS and allows you to drag the
textCtrl smoothly around the screen? And, if it doesn't allow dragging on
Mac, why not? (It works on WinXP). (Written with wxPython 2.8.10.1, Python
2.5).

I don’t own a Mac, so would some kind Mac owner please test whether the

attached 58 line program runs on (a recent) MacOS and allows you to drag the

textCtrl smoothly around the screen? And, if it doesn’t allow dragging on

Mac, why not? (It works on WinXP). (Written with wxPython 2.8.10.1, Python

2.5).

It allows me to drag it in 2.8.10.1 (Python 2.6, OS 10.6.8),

Thanks for testing it.

but it’s
not very smooth - it seems to stop dragging of its own accord, perhaps when I’m especially jerky with the mouse.

Hmm, it’s pretty smooth on Windows and never stops dragging.

It wasn’t obvious how to drag it either; I had to click on a narrow strip no more than 2 pixels (if that) around the border.

On Windows I can click anywhere on the textCtrl, hold, and drag.

With 2.9.3.1 and wxOSX-Cocoa it doesn’t work at all, but lots of other

stuff doesn’t either.

Does anyone know why?

What does a wxPython programmer need to know vis-a-vis Cocoa vs…what? Carbon? (My knowledge of Macs is close to limited to “they tend to be white”).

This brings me to my larger point… I have not yet ever tried running things on Mac, but I am sending some stuff to a friend who only runs Mac, and I’d like things to work. What does a Windows person need to know to steer clear of the most obvious cross-platform breakers? Or is it pretty much that I’d need a Mac to even try to collaborate with him?

Nothing vital here, just wanted to send some fun things my Mac friend’s way.

Che

···

On Mon, Feb 13, 2012 at 6:04 PM, Nat Echols nathaniel.echols@gmail.com wrote:

On Mon, Feb 13, 2012 at 2:58 PM, C M cmpython@gmail.com wrote:

You can't depend on being able to get all the mouse events (and key events sometimes) from the native widgets. There is just no way that wx can guarantee that they will always be delivered without risking breaking the native functionality of those widget types that want to handle the events themselves in some non-standard way.

I have a couple suggestions for a workaround. The first would be to parent the textctrl on a panel that is a little larger than the textctrl, say 10 pixels on each side. (Or perhaps you reparent the textctrl onto the panel when your program goes into "edit mode" or what ever you want to call it. You can even make the panel be a different color or paint grabber rectangles onto it or something to indicate that it should be where the user grabs the widget to move or resize it. Using the appropriate cursors for the panel would also be good. Then you put your mouse event handling functionality on that panel instead of the native widget.

The other suggestion would be that when you go into "edit mode" or whatever you want to call it that you replace the textctrl with a wx.lib.statbmp bitmap that looks like the textctrl, and drag that around instead.

···

On 2/13/12 2:58 PM, C M wrote:

I don't own a Mac, so would some kind Mac owner please test whether the
attached 58 line program runs on (a recent) MacOS and allows you to drag
the textCtrl smoothly around the screen? And, if it doesn't allow
dragging on Mac, why not? (It works on WinXP). (Written with wxPython
2.8.10.1, Python 2.5).

--
Robin Dunn
Software Craftsman

The other suggestion would be that when you go into “edit mode” or whatever you want to call it that you replace the textctrl with a wx.lib.statbmp bitmap that looks like the textctrl, and drag that around instead.

Thanks, Robin.

I like this suggestion even more than the parent-it-on-a-draggable-panel one, in that the hit area is much larger, so it is better in terms of Fitt’s Law. In fact, I’d be inclined to leave it in statbmp (and thus draggable) form until it goes into edit mode, then switch it to the textCtrl for the user to type.

My question is what’s the best 2012-and-cross-platform way to get the bitmap of the textctrl (with its current content)? There are a number of recipes for screenshots online, but the first one I tried didn’t work, another mentioned cross-platform tweaking…and so I thought I’d ask what the state of the art is.

Che

It's probably mostly the same as what you've seen already. When compositing is involved it may or may not be possible to get anything back from a wx.ScreenDC (assuming that is the approach you've tried.) You can try using its GetAsBitmap method and the extracting the portion of the screen you want from that, but it still may not work everywhere.

···

On 2/14/12 1:57 PM, C M wrote:

    The other suggestion would be that when you go into "edit mode" or
    whatever you want to call it that you replace the textctrl with a
    wx.lib.statbmp bitmap that looks like the textctrl, and drag that
    around instead.

Thanks, Robin.

I like this suggestion even more than the parent-it-on-a-draggable-panel
one, in that the hit area is much larger, so it is better in terms of
Fitt's Law. In fact, I'd be inclined to leave it in statbmp (and thus
draggable) form until it goes into edit mode, then switch it to the
textCtrl for the user to type.

My question is what's the best 2012-and-cross-platform way to get the
bitmap of the textctrl (with its current content)? There are a number
of recipes for screenshots online, but the first one I tried didn't
work, another mentioned cross-platform tweaking...and so I thought I'd
ask what the state of the art is.

--
Robin Dunn
Software Craftsman