Recent

Author Topic: Right-click on TDBGrid does not scroll database  (Read 3244 times)

HatForCat

  • Sr. Member
  • ****
  • Posts: 293
Right-click on TDBGrid does not scroll database
« on: March 16, 2017, 07:47:51 pm »
With a right-click on a TDBGrid for my Popup menu, this same program-code in windows (Delphi) will first scroll the database to the Row under the mouse-cursor before the right-click.

This may be a Ubuntu thing, but Lazarus uses the current highlighted Row which may not be the Row under the cursor when the right-click was done.

Is there an option to make his work the same in Lazarus+SQLdb?

Thanks


Acer-i5, 2.6GHz, 6GB, 500GB-SSD, Mint-19.3, Cinnamon Desktop, Lazarus 2.0.6, SQLite3

Thaddy

  • Hero Member
  • *****
  • Posts: 14373
  • Sensorship about opinions does not belong here.
Re: Right-click on TDBGrid does not scroll database
« Reply #1 on: March 16, 2017, 08:51:40 pm »
This is not only on Windows and it is by design: A right click should not assume anything - and this is documented in e.g. the Windows design guidelines! -but the current state. So basically Delphi is misbehaving.
But there's no reason why you could not implement this behavior yourself and make the record beneath the mouse cursor current in one of the OnMouseXXX events.
Maybe a good time to study how other programs behave with a right mouseclick... there's a reason for that....
It is all about current state and current context, irrespectively of where you click the right mouse button in the focused control. A right click should not have a mind of its own and update the context.....
So if you want it, program it. Easy task. Not recommended in the light of the above. It confuses users.
If Delphi does it, then that's Delphi's mistake.
« Last Edit: March 16, 2017, 09:02:37 pm by Thaddy »
Object Pascal programmers should get rid of their "component fetish" especially with the non-visuals.

Zoran

  • Hero Member
  • *****
  • Posts: 1830
    • http://wiki.lazarus.freepascal.org/User:Zoran
Re: Right-click on TDBGrid does not scroll database
« Reply #2 on: March 16, 2017, 09:34:24 pm »
In DBGrid you can just set dgAnyButtonCanSelect in Options property.

Thaddy

  • Hero Member
  • *****
  • Posts: 14373
  • Sensorship about opinions does not belong here.
Re: Right-click on TDBGrid does not scroll database
« Reply #3 on: March 16, 2017, 10:00:03 pm »
That's actually a neat solution I didn't think about.
Still. It is a bad idea in the bigger picture: try to always mimic the user experience that is common on a platform. You can make people (oh well, normal users) really frustrated when a program doesn't behave like all other programs on the same platform. Some people (programmers)  think that is not important and they know better, well believe me, I used to make those mistakes 20 years ago.
If you want to improve on a platform, discuss on the platform...
Object Pascal programmers should get rid of their "component fetish" especially with the non-visuals.

HatForCat

  • Sr. Member
  • ****
  • Posts: 293
Re: Right-click on TDBGrid does not scroll database
« Reply #4 on: March 18, 2017, 11:07:12 pm »
In DBGrid you can just set dgAnyButtonCanSelect in Options property.

Awesome, thanks Zoran. I was pretty sure that Lazarus would have had the situation covered, just could not find out what term to search on to find it.

It works perfectly.

@Thaddy: I agree with you on the fundamental philosophy, but note that msoft wrote the book on mandatory methods for GUI behavior, then broke their own rules, thus legitimizing sloppy behavior by example.
Acer-i5, 2.6GHz, 6GB, 500GB-SSD, Mint-19.3, Cinnamon Desktop, Lazarus 2.0.6, SQLite3

 

TinyPortal © 2005-2018