Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed nTop not being incremented in ListBox:hitTest() for no-box dropdown #372

Merged
merged 1 commit into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions ChangeLog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@
Entries may not always be in chronological/commit order.
See license at the end of file. */

2025-01-09 12:00 UTC+0100 Kamil Przybylski (kprzybylski quay.pl)
* src/rtl/listbox.prg
! fixed nTop not being incremented in ListBox:hitTest() for no-box dropdown
* replaced inconsistent references to ::nTop with nTop
* renamed variables to better reflect their role

2025-01-08 13:14 UTC+0100 Kamil Przybylski (kprzybylski quay.pl)
* src/rtl/listbox.prg
! fixed nTop variable not being assigned properly in ListBox:hitTest()
Expand Down
33 changes: 16 additions & 17 deletions src/rtl/listbox.prg
Original file line number Diff line number Diff line change
Expand Up @@ -396,8 +396,8 @@ METHOD getText( nPos ) CLASS ListBox

METHOD hitTest( nMRow, nMCol ) CLASS ListBox

LOCAL nRet
LOCAL nTop := ::nTop
LOCAL nOffset := 0
LOCAL nHit := 0

/* Check hit on the scrollbar */
Expand All @@ -408,13 +408,13 @@ METHOD hitTest( nMRow, nMCol ) CLASS ListBox
RETURN nHit
ENDIF

IF ! ::lIsOpen .OR. Empty( ::cHotBox + ::cColdBox )
nRet := 0
ELSE
IF ::lDropDown
nTop++
ENDIF
IF ::lIsOpen .AND. ::lDropDown
nTop++
ENDIF

IF ::lIsOpen .AND. .NOT. Empty( ::cHotBox + ::cColdBox )
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you could rewrite this line to be IF ::lIsOpen .AND. ! Empty( ::cHotBox + ::cColdBox )
and add some comment/note that here we're extending over Cl*pper's abilites, then I think your patch is okay to be pulled in.


nOffset := 1
DO CASE
CASE nMRow == nTop
DO CASE
Expand All @@ -435,35 +435,34 @@ METHOD hitTest( nMRow, nMCol ) CLASS ListBox
RETURN HTBOTTOM
ENDCASE
CASE nMCol == ::nLeft
IF nMRow >= ::nTop .AND. ;
IF nMRow >= nTop .AND. ;
nMRow <= ::nBottom
RETURN HTLEFT
ELSE
RETURN HTNOWHERE
ENDIF
CASE nMCol == ::nRight
IF nMRow >= ::nTop .AND. ;
IF nMRow >= nTop .AND. ;
nMRow <= ::nBottom
RETURN HTRIGHT
ELSE
RETURN HTNOWHERE
ENDIF
ENDCASE
nRet := 1
ENDIF

DO CASE
CASE ! ::lIsOpen
CASE nMRow < nTop + nRet
CASE nMRow > ::nBottom - nRet
CASE nMCol < ::nLeft + nRet
CASE nMCol <= ::nRight - nRet
RETURN ::nTopItem + nMRow - ( nTop + nRet )
CASE nMRow < nTop + nOffset
CASE nMRow > ::nBottom - nOffset
CASE nMCol < ::nLeft + nOffset
CASE nMCol <= ::nRight - nOffset
RETURN ::nTopItem + nMRow - ( nTop + nOffset )
ENDCASE

DO CASE
CASE ! ::lDropDown
CASE nMRow != ::nTop
CASE nMRow != nTop
CASE nMCol < ::nLeft
CASE nMCol < ::nRight
RETURN HTCLIENT
Expand All @@ -479,7 +478,7 @@ METHOD hitTest( nMRow, nMCol ) CLASS ListBox
RETURN HTCAPTION
ENDCASE

RETURN 0
RETURN HTNOWHERE

METHOD insItem( nPos, cText, xData ) CLASS ListBox

Expand Down
Loading