Recent

Author Topic: How to bypass an inherited method in immediate ancestor  (Read 3608 times)

Joanna

  • Hero Member
  • *****
  • Posts: 723
How to bypass an inherited method in immediate ancestor
« on: October 14, 2021, 07:24:37 am »
Hello everyone;
I’m trying to make the tcheckcombobox work better. I have made a new class that inherits tcheckcombobox and I’m trying to override the keydown event. However probably need to call the keydown event for tcustomcombobox combobox how do I access that method without calling the event in tcheckcombobox.keydown first? Since that is the most immediate ancestor . I’ve Already tried typecasting to tcustomcombobox and that didn’t work .
✨ 🙋🏻‍♀️ More Pascal enthusiasts are needed on IRC .. https://libera.chat/guides/ IRC.LIBERA.CHAT  Ports [6667 plaintext ] or [6697 secure] channel #fpc  Please private Message me if you have any questions or need assistance. 💁🏻‍♀️

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: How to bypass an inherited method in immediate ancestor
« Reply #1 on: October 14, 2021, 08:32:49 am »
However probably need to call the keydown event for tcustomcombobox combobox how do I access that method without calling the event in tcheckcombobox.keydown first? Since that is the most immediate ancestor
isn't one of the problems of inheritance (and OOP)? maybe you want to try a different approach?!
Instead of trying to hack through the ancestor, simply copy/paste the existing implementation and modify the copy to your needs.
« Last Edit: October 14, 2021, 08:38:58 am by skalogryz »

wp

  • Hero Member
  • *****
  • Posts: 11853
Re: How to bypass an inherited method in immediate ancestor
« Reply #2 on: October 14, 2021, 10:36:59 am »
I’m trying to make the tcheckcombobox work better.

Joanna, just want to tell you that I am attempting to fix TCheckComboBox. The problem is the usage of platform-defines {$IF DEFINED(LCLWin32)) inside the LCL which is not allowed. I am following two ideas: either integrate the component into the LCL widgetset interface system, or move the component out of the LCL into a separate package, e.g. LazControls. ATM I am favouring the second approach which is much easier (however, breaks user code since projects must add LazControls to their requirements then).

Both ways will fix the buggy behaviour of the component with the dropdown in Windows.

But in order to improve usabilitiy of the component there are other issues to be solved:
- check/uncheck items only when the checkbox is clicked, not when the item is clicked somewhere else
- display a list of the checked items in the non-dropped case so that the user can see the checked item without having to drop down the combo.

howardpc

  • Hero Member
  • *****
  • Posts: 4144
Re: How to bypass an inherited method in immediate ancestor
« Reply #3 on: October 14, 2021, 12:19:33 pm »
But in order to improve usabilitiy of the component there are other issues to be solved:
- check/uncheck items only when the checkbox is clicked, not when the item is clicked somewhere else
Speaking only for myself, I rather like this feature that clicking anywhere on the text of the item toggles the checked status. But perhaps it flouts some GUI guidelines or widgetset protocol?

Joanna

  • Hero Member
  • *****
  • Posts: 723
Re: How to bypass an inherited method in immediate ancestor
« Reply #4 on: October 15, 2021, 02:40:51 am »
Wp I’m glad you are trying to fix it. Apart from the occasional crash the tcheckcombobox in lazarus 1.6.4 was far more pleasant to use.
I’m not content with merely clicking the checkcombobox I need to be able to use keydown events like arrow keys, escape ,space bar and return.

The checkcombobox seems to get stuck in the dropped down state and is often impossible to close. When the form is moved it floats in the same spot. When I’m trying to trace into the code the floating dropdown floats directly over the code in editor which I’m trying to examine and prevents me from reading it unless I scroll the editor.

Showing everything that is checked in the non dropped state would be completely unusable for me because I have a long list of items. The entire reason I’m using the checkcombobox is to save space.
I hope that will be an optional setting if you implement it.

I prefer being able to click anywhere on the item to toggle as well instead of having to aim for a small checkbox.

I tried some code yesterday that will toggle selected item with space bar but I don’t know how to refresh the toggled state in the dropdown part. I tried setting dropped down to false then true but that didn’t do anything.


« Last Edit: October 15, 2021, 04:16:04 am by Joanna »
✨ 🙋🏻‍♀️ More Pascal enthusiasts are needed on IRC .. https://libera.chat/guides/ IRC.LIBERA.CHAT  Ports [6667 plaintext ] or [6697 secure] channel #fpc  Please private Message me if you have any questions or need assistance. 💁🏻‍♀️

wp

  • Hero Member
  • *****
  • Posts: 11853
Re: How to bypass an inherited method in immediate ancestor
« Reply #5 on: October 26, 2021, 11:38:00 pm »
Spent some time with this component, but finally concluded that many of its issues originate in the fact that it just is a combobox and is not made for this (e.g. closing up after a selection has been made). Therefore, I attempted to rewrite it from ground up, based on TEditButton. The dropdown window displays a TCheckListbox, and in total it almost behaves as i would expect it - see https://wiki.freepascal.org/ExCtrls#TCheckComboBoxEx. Download from ccr, package ExCtrls, unit excheckcombo (https://sourceforge.net/p/lazarus-ccr/svn/HEAD/tree/components/exctrls/source/excheckcombo.pas). There is also a demo in https://sourceforge.net/p/lazarus-ccr/svn/HEAD/tree/components/exctrls/examples/CheckComboBoxEx/.

The problem that I still see is that the dropped-down list must be able to reach out of the parenting form. Therefore, I put the CheckListbox into its own form - and this makes the parenting form becoming deactivated when the list drops down. Besides the form caption being painting in its deactivated color, this may also cause trouble in applications which do not expect OnDeactivate and OnActivate event here.

 

TinyPortal © 2005-2018