I’m new to JUCE, and I’m having a problem with unexpected behaviour for the I-Beam cursor.
When the cursor is an I-Beam, the x-coordinate passed to Component::mouseDown() is about two pixels left of where I’d expect it to be. To demonstrate this, I’ve put together a small test program that draws a vertical red line where the click was received (see attached screenshot of the program in action). I would have expected to red line to be perfectly aligned with the centre of the IBeam cursor.
Here’s a screenshot of how the application looks when it has received a click - note that the centre of the IBeam and the red line are not aligned:
[attachment=0]juce_2.png[/attachment]
Is this the correct behaviour, or am I missing something? (e.g. perhaps I’m grabbing the wrong coord, or maybe I should be offsetting the coordinates by some number of pixels for the window border, or maybe this is just how Windows returns IBeam coords? ).
Thanks,
M.
Some version info:
JUCE version: 1.52, and also today’s lastest from git
OS: Windows 7 64 bit
Here’s a minimal application that demonstrates what I’m doing:
Well, your demo app works perfectly for me (in Vista). There can’t really be any problem with the actual position - this must be just the fact that in your windows set-up, the hot-spot for that cursor shape has been positioned off-centre - no idea how or why that’d happen though!
That’s strange! This is a standard Win7 install, and I haven’t done anything like modify the cursors etc.
Perhaps someone else who’s reading this and runs Windows 7 can try the demo app? That would allow us to determine is it’s something specific to Windows 7 or there is something strange going on locally…
[quote=“ckk”]I can also reproduce the x-offset with Win7/64-bit.
Chris[/quote]
Thanks for trying that Chris, it’s useful to know that this is affecting other Windows 7 users. (I’m also using the 64 bit version of Win7 - I’ll edit my original post to mention this).
Not sure if it’s relevant, but I’m using an NVidia video card with the latest drivers (v270.61). The problem also occurs with older drivers (v258.96).
The problem occurs both with and without the Aero theme enabled.
Although we’ve established that this problem is not caused by JUCE, I’m pretty sure that finding the answer to this is in the interests of most JUCE developers targetting Windows 7 (as most of us need a pixel-accurate I-Beam pointer).
Therefore, I thought it’s worth mentioning that I’ve posted details of the problem in a question on Stack Overflow. If you’re interested in finding the answer, it would be very helpful if you could give the question on Stack Overflow an up-vote please, as this should attract more interest from people who can help. The question is here:
(A quick summary of the extra information that I’ve discovered since last posting about this on the JUCE forum: I’ve dumped out the hotspot information and the pointer bitmap for the I-Beam. There is indeed a two pixel discrepency between the x-coord of the hotspot and the pointer image in the bitmap. The big question is how could this discrepency occur on a default install of Windows 7 64-bit?).
Why don’t we just create a correct i-beam cursor and include it in Juce using BinaryBuilder? Juce can have two cursors, one for the standard system provided and the other for the corrected version.
That would be a good workaround, but I think we’d first need to establish:
a) Is this problem definitely just a case of an incorrect I-Beam hotspot for the default system cursor set? (as opposed to programmer error)
b) If so, which versions of windows does this affect?
It feels slightly wrong to add things to JUCE if we don’t yet 100% understand the extent of problem we want to solve.