I just ran into an interesting problem, which I've already resolved, but I thought I'd share it here in case it bites anyone else.
I'm working on an app, one feature of which is that you can introduce labels at runtime, and drag them around over your document (kind of like attaching annotations in a PDF viewer). In my
MouseDown event handler, I wanted to check that it was the left button that was pressed, and that no modifier keys were being used, so I wrote:
if (Button = mbLeft) and (Shift = []) then begin ... end
At the time I wrote this, I was developing on a Raspberry Pi, connected remotely using TightVNC. The code above didn't work because
Shift contained
ssLeft. So I changed it to:
if (Button = mbLeft) and (Shift = [ssLeft]) then begin ... end
After that, it worked as expected. However, when I went to go test the app on the Raspberry Pi's own local X server, it no longer worked. I discovered that there,
Shift was actually an empty set, as I had originally expected it to be.
My fix was to rewrite the code like this:
if (Button = mbLeft) and (Shift * [ssShift,ssCtrl,ssAlt] = []) then begin ... end
This worked properly in both environments.