ListIconGadget has no left & right keyboard scroll

Mac OSX specific forum
DayDreamer
User
User
Posts: 31
Joined: Thu Aug 03, 2023 5:44 pm
Location: Off Planet

ListIconGadget has no left & right keyboard scroll

Post by DayDreamer »

I'm doing development on a Mac M1 running Ventura with PB 6.02. I have found an apparent bug with the ListIconGadget not having any keyboard left and right arrow horizontal scrolling support for content that extends beyond the width of the the gadget. Is anyone else experiencing this problem?

I have enabled my general computer settings such that horizontal and vertical scroll bars are always displayed, and they appear in the ListIconGadget when running my app. Horizontal scrolling is only possible by movement of the mouse cursor onto the horizontal bar and "dragging" the content over using the horizontal bar.

Other standard apps on my Mac all support the left and right arrow keys for keyboard horizontal scrolling ok with list boxes of those apps. So, my problem is definitely unique to the compiled output of PB and the ListIconGadget.

Hope someone can offer some advice or work arounds perhaps, e.g. is there a Cocoa based approach?
Fred
Administrator
Administrator
Posts: 18220
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: ListIconGadget has no left & right keyboard scroll

Post by Fred »

Could you post a source code ? Can anybody else confirm ?
DayDreamer
User
User
Posts: 31
Joined: Thu Aug 03, 2023 5:44 pm
Location: Off Planet

Re: ListIconGadget has no left & right keyboard scroll

Post by DayDreamer »

The following code example app template, when compiled, simply shows the ListIconGadget at full app window width and half app window height with multiple columns (no data). The horizontal scroll bar is shown, however, left and right arrow keys do not work. When scrolling the list using the mouse and dragging the horizontal scroll bar, the listiconbox does move, but does not go full way to show last column. I hope someone can point out any issues with the code that may be explain why left and right arrow keys on listicongadget do not work and why horizontal scrolling for full width to show last column does not work with mouse.

Code: Select all

;--- START OF CODE
#wTitleApp = "Test Application"
#wWidthMain = 800
#wHeightMain = 600

Enumeration
  ; Window ID
  #winMain
  ; Gadget ID
  #gdtList
  ; Keyboard
  #keyReturn
  #keyTab
  #keyBackTab
  #keyEscape
EndEnumeration

;
; Create_winKB
;
Procedure Create_winKB(winID.i)
  
  AddKeyboardShortcut(winID, #PB_Shortcut_Return, #keyReturn)
  AddKeyboardShortcut(winID, #PB_Shortcut_Tab, #keyTab)
  AddKeyboardShortcut(winID, #PB_Shortcut_Tab | #PB_Shortcut_Shift, #keyBackTab)  
  AddKeyboardShortcut(winID, #PB_Shortcut_Escape, #keyEscape)
  
EndProcedure

;
; LoadListIcon
;
Procedure LoadListIcon(gdtList.i)

  ; Empty list gadget.
  ClearGadgetItems(gdtList)
  
  ; Clear all list columns
  RemoveGadgetColumn(gdtList, #PB_Any)
  
  ; Add columns
  
  AddGadgetColumn(gdtList, 0, "Column 1", 250)
  AddGadgetColumn(gdtList, 1, "Column 2", 250)
  AddGadgetColumn(gdtList, 2, "Column 3", 250)
  AddGadgetColumn(gdtList, 3, "Column 4", 250)
  AddGadgetColumn(gdtList, 4, "Column 5", 250)
  
EndProcedure

;
; Create_winMainGadget
;
Procedure Create_winMainGadget()
  
  ListIconGadget(#gdtList, 0, 0, WindowWidth(#winMain), WindowHeight(#winMain)/2, "", 0)
  LoadListIcon(#gdtList)
  SetActiveGadget(#gdtList)
  
EndProcedure

;
; Process_winMainKB
;
Procedure Process_winMainKB()
  
  Select EventMenu()
    ;  
    ; Esc key triggered action to close window.
    ;
    Case #keyEscape
      PostEvent(#PB_Event_CloseWindow, #winMain, 0)
      
    Case #keyTab
      
    Case #keyBackTab
      
    Case #keyReturn
      
  EndSelect
  
EndProcedure

;
; Process_winMainGadget
;
Procedure Process_winMainGadget()

EndProcedure

;
; Process_winMainResize
;
Procedure Process_winMainResize()
  
  ResizeGadget(#gdtList, 0, 0, WindowWidth(#winMain), WindowHeight(#winMain)/2)
  
EndProcedure

;
; Show_winMain
;
Procedure Show_winMain()
  
  Protected Quit_winMain.b = #False
  
  If OpenWindow(#winMain, 0, 0, #wWidthMain, #wHeightMain, #wTitleApp, 
                #PB_Window_TitleBar | #PB_Window_SystemMenu | #PB_Window_ScreenCentered |
                #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget |
                #PB_Window_SizeGadget)
    
    Create_winKB(#winMain)
    Create_winMainGadget()

    Repeat
      Select WaitWindowEvent()
        Case #PB_Event_CloseWindow
          Quit_winMain = #True
          
        Case #PB_Event_Menu          
          Process_winMainKB()

        Case #PB_Event_Gadget
          Process_winMainGadget()
          
        Case #PB_Event_SizeWindow
          Process_winMainResize()
          
      EndSelect
    Until Quit_winMain = #True
    
    RemoveKeyboardShortcut(#winMain, #PB_Shortcut_All)
    CloseWindow(#winMain)
      
  EndIf
  
EndProcedure

Procedure main()
  
  Show_winMain()
  
EndProcedure

main()

;--- END OF CODE
DayDreamer
User
User
Posts: 31
Joined: Thu Aug 03, 2023 5:44 pm
Location: Off Planet

Re: ListIconGadget has no left & right keyboard scroll

Post by DayDreamer »

I still do not know why the left and right arrow keys are not active to allow horizontal scrolling with the sample code. That is bug number 1.

There is also a bug number 2 with this code, which is that scrolling horizontally does work via mouse drag (left click and hold while moving mouse) but about 95% of last column is truncated. I have found a work around for this second bug which will enable full visibility of last data column. It can be achieved by making the current last column actually the second last column by inserting an extra column after it. I.e.

AddGadgetItem(gdtList, 5, "", 0)

Therefore, it is the dummy placeholder column that gets truncated and prior column is fully scrolled into view via mouse scroll.

I would really appreciate if someone in the PureBasic genius community could shed some light on my bug number 1 - why don't keyboard arrow keys become active to allow keyboard horizontal scrolling left or right?
User avatar
Piero
Addict
Addict
Posts: 923
Joined: Sat Apr 29, 2023 6:04 pm
Location: Italy

Re: ListIconGadget has no left & right keyboard scroll

Post by Piero »

6.02 Monterey M1

Scroll works here, but I mean swiping with two fingers on MacBook, and last column opens OK.

edit: If I set OS prefs to "scrollbars always visible", last column opens truncated!

But if I resize window, on each run/resize different kinds of strange things MAY happen with last column (truncates, enlarges alone…)

Image
User avatar
mk-soft
Always Here
Always Here
Posts: 6246
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: ListIconGadget has no left & right keyboard scroll

Post by mk-soft »

PB v6.03 Beta 5 (Intel)
Since Bate 5 is "sizeLastColumnToFit" removed. Here all columns complete visible.

The way I read it, the left and right keys are not standard and have to be intercepted themselves.
But I could also be wrong.
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
User avatar
Piero
Addict
Addict
Posts: 923
Joined: Sat Apr 29, 2023 6:04 pm
Location: Italy

Re: ListIconGadget has no left & right keyboard scroll

Post by Piero »

BTW, maybe you can use shift-mouseScroll (may need to be enabled in OS prefs; I don't have Ventura)
DayDreamer
User
User
Posts: 31
Joined: Thu Aug 03, 2023 5:44 pm
Location: Off Planet

Re: ListIconGadget has no left & right keyboard scroll

Post by DayDreamer »

So, is support for left and right arrow keys NOT provided as standard functionality for the ListIconGadget, yet up and down arrow keys definitely are enabled? Interesting ... if so, then provided gadget documentation should convey this and my hullabaloo is simply a whinge about missing documentation? I hope I'm wrong. I too confirm two finger swipe across mouse track area performs horizontal scroll on my M1 Mac laptop. It's just the keyboard behaviour that appears lacking ... Thank you for feedback provided so far.
User avatar
Piero
Addict
Addict
Posts: 923
Joined: Sat Apr 29, 2023 6:04 pm
Location: Italy

Re: ListIconGadget has no left & right keyboard scroll

Post by Piero »

DayDreamer wrote: Thu Aug 24, 2023 3:50 pm So, is support for left and right arrow keys NOT provided as standard functionality
Can you provide an example of a standard OS app using L/R arrows or left-click/drag to scroll horizontally?
I'm curious... did you see what L/R arrows do in Finder? (option-rightArrow opens all contained folders of a selected folder in list view... it also needed command, long time ago…)
User avatar
Piero
Addict
Addict
Posts: 923
Joined: Sat Apr 29, 2023 6:04 pm
Location: Italy

Re: ListIconGadget has no left & right keyboard scroll

Post by Piero »

DayDreamer wrote: Thu Aug 24, 2023 3:50 pmconvey this and my hullabaloo is simply a whinge
Esticazzi?

PS: forgive my "Italian"
DayDreamer
User
User
Posts: 31
Joined: Thu Aug 03, 2023 5:44 pm
Location: Off Planet

Re: ListIconGadget has no left & right keyboard scroll

Post by DayDreamer »

:shock: I am eating humble pie. My assertion of no left & right keyboard scroll support appears to be an assumption on my part. My return to coding after a long absence still is influenced by outdated ui standards I recall from my Windows development days where my professional dev standards included keyboard left and right keys being enabled for horizontal scrolling of list views, if needed. I assumed that carried over for the Mac and use of PureBasic ... which I've chosen for new cross platform work because it is a beautiful and simple implementation. Just love it.

To confirm. Horizontal scrolling can be achieved with ListIconGadget in following ways as standard on Mac.
1. Mouse over and drag of horizontal scroll bar.
2. Two finger swipe over mouse track area.
3. Holding shift key and using a middle mouse scroll.

There is no standard for using left and right arrow keys. The only third party app I have confirmed where left and right arrow keys support horizontal scrolling in a list is the open source app Calibre.

So, this thread can be closed with my most respectful thanks for feedback and pushback.

Now the new challenge, how to enable a cross platform solution for left and right arrow keyboard horizontal scrolling for the list icon gadget? No idea how I'm going to solve that. Yet!
User avatar
mk-soft
Always Here
Always Here
Posts: 6246
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: ListIconGadget has no left & right keyboard scroll

Post by mk-soft »

You have to redirect the keyDown from NSListView and do the scrolling yourself.
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
benubi
Enthusiast
Enthusiast
Posts: 220
Joined: Tue Mar 29, 2005 4:01 pm

Re: ListIconGadget has no left & right keyboard scroll

Post by benubi »

Hi

I am not sure if I understood your problem correctly. The way I understand it you want to navigate through the ListIconGadget using the arrow keys.

1) The right side (vertical) scroll bar only appears if you have more list items than can be displayed in the rectangle. An empty list does not need a vertical scrollbar (what should it indicate except taking 100% of the space and doing nothing when you click on it)

2) You have a horizontal scroll bar because the columns size is bigger than the ListIconGadget rectangle width.


3) I have never tried using arrow keys to navigate through a ListIconGadget. The behavior should be normal OS behavior. When I start the example code provided above, I can scroll left/right (horizontally) using the mousewheel.

4) When I add Items, the behavior changes once a vertical SB is present - now mousewheel will scroll up/down... and now I can use arrows to navigate.


This works with arrow keys on Windows 10, PB 6.02 LTS:

Code: Select all

;--- START OF CODE
#wTitleApp = "Test Application"
#wWidthMain = 800
#wHeightMain = 600

Enumeration
  ; Window ID
  #winMain
  ; Gadget ID
  #gdtList
  ; Keyboard
  #keyReturn
  #keyTab
  #keyBackTab
  #keyEscape
EndEnumeration

;
; Create_winKB
;
Procedure Create_winKB(winID.i)
  
  AddKeyboardShortcut(winID, #PB_Shortcut_Return, #keyReturn)
  AddKeyboardShortcut(winID, #PB_Shortcut_Tab, #keyTab)
  AddKeyboardShortcut(winID, #PB_Shortcut_Tab | #PB_Shortcut_Shift, #keyBackTab)  
  AddKeyboardShortcut(winID, #PB_Shortcut_Escape, #keyEscape)
  
EndProcedure

;
; LoadListIcon
;
Procedure LoadListIcon(gdtList.i)

  ; Empty list gadget.
  ClearGadgetItems(gdtList)
  
  ; Clear all list columns
  RemoveGadgetColumn(gdtList, #PB_Any)
  
  ; Add columns
  
  AddGadgetColumn(gdtList, 0, "Column 1", 250)
  AddGadgetColumn(gdtList, 1, "Column 2", 250)
  AddGadgetColumn(gdtList, 2, "Column 3", 250)
  AddGadgetColumn(gdtList, 3, "Column 4", 250)
  AddGadgetColumn(gdtList, 4, "Column 5", 250)
  
EndProcedure

;
; Create_winMainGadget
;
Procedure Create_winMainGadget()
  
  ListIconGadget(#gdtList, 0, 0, WindowWidth(#winMain), WindowHeight(#winMain)/2, "", 0)
  LoadListIcon(#gdtList)
  SetActiveGadget(#gdtList)
  
EndProcedure

;
; Process_winMainKB
;
Procedure Process_winMainKB()
  
  Select EventMenu()
    ;  
    ; Esc key triggered action to close window.
    ;
    Case #keyEscape
      PostEvent(#PB_Event_CloseWindow, #winMain, 0)
      
    Case #keyTab
      
    Case #keyBackTab
      
    Case #keyReturn
      
  EndSelect
  
EndProcedure

;
; Process_winMainGadget
;
Procedure Process_winMainGadget()

EndProcedure

;
; Process_winMainResize
;
Procedure Process_winMainResize()
  
  ResizeGadget(#gdtList, 0, 0, WindowWidth(#winMain), WindowHeight(#winMain)/2)
  
EndProcedure

;
; Show_winMain
;
Procedure Show_winMain()
  
  Protected Quit_winMain.b = #False
  
  If OpenWindow(#winMain, 0, 0, #wWidthMain, #wHeightMain, #wTitleApp, 
                #PB_Window_TitleBar | #PB_Window_SystemMenu | #PB_Window_ScreenCentered |
                #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget |
                #PB_Window_SizeGadget)
    
    Create_winKB(#winMain)
    Create_winMainGadget()
    
    Protected i 
    For i=1 To 100
      AddGadgetItem(#gdtList,-1,"List item #"+Str(i))  
    Next
    

    Repeat
      Select WaitWindowEvent()
        Case #PB_Event_CloseWindow
          Quit_winMain = #True
          
        Case #PB_Event_Menu          
          Process_winMainKB()

        Case #PB_Event_Gadget
          Process_winMainGadget()
          
        Case #PB_Event_SizeWindow
          Process_winMainResize()
          
      EndSelect
    Until Quit_winMain = #True
    
    RemoveKeyboardShortcut(#winMain, #PB_Shortcut_All)
    CloseWindow(#winMain)
      
  EndIf
  
EndProcedure

Procedure main()
  
  Show_winMain()
  
EndProcedure

main()

;--- END OF CODE
Edit: forget it, I'm on Windows and that's a Mac problem :oops: sorry!
Last edited by benubi on Fri Aug 25, 2023 1:43 pm, edited 2 times in total.
User avatar
mk-soft
Always Here
Always Here
Posts: 6246
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: ListIconGadget has no left & right keyboard scroll

Post by mk-soft »

Ok,
After a long search, I have found a solution.
The NSTableView has no keyboard functions like keyDown.
So with AddKeyboardShortCut left and right. But only if the ListIconGadget has the focus.

Then there was the search for scrolling. There were several solutions that did not work as they should.
It took me a while to find the right class method.

Update 3
- Optimize to Column width
- Scroll position

Link: ListIconGadget with Left and Right Keys

Code: Select all

; See Link
Last edited by mk-soft on Fri Aug 25, 2023 3:18 pm, edited 1 time in total.
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
DayDreamer
User
User
Posts: 31
Joined: Thu Aug 03, 2023 5:44 pm
Location: Off Planet

Re: ListIconGadget has no left & right keyboard scroll

Post by DayDreamer »

Hi mk-soft!

Wow. :D

Thank you for making time for investigating and providing a solution for left and right arrow keyboard support for the ListIconGadget for the Mac environment.

I really appreciate your expertise and brilliance. Great job.
Post Reply