Page 1 of 2

Setting focus on ListIconGadget

Posted: Sat Nov 20, 2021 1:51 pm
by firace
Any tricks to set the focus on the listicongadget's items, so that keyboard navigation with the arrow keys is immediately possible?

I've tried SetActiveGadget, but this sets focus on the listicon's column headers...

Code: Select all

CloseDebugOutput()

OpenWindow(0, 10, 20, 1200, 550, "Demo ", #PB_Window_BorderLess)  :  SetWindowColor(0, #White)

TextGadget(200, 50, 20, 600, 50, "<font size=6><b>Demo SB Dashboard</b></font>")

ListIconGadget(1,4, 110,887,310,  "Col 0", 50) 

AddGadgetColumn(1, 1,          "Col 1",   40) 
AddGadgetColumn(1, 2,          "Col 2",   60) 
AddGadgetColumn(1, 4,          "Col 3",   60)
AddGadgetColumn(1, 5,          "Col 4",   60)
AddGadgetColumn(1, 6,          "Col 5",   50)
AddGadgetColumn(1, 6,          "Col 6",   50)

AddGadgetItem(1, -1, "Item 1")
AddGadgetItem(1, -1, "Item 2")
AddGadgetItem(1, -1, "Item 3")

SetActiveGadget(1)

Re: Setting focus on ListIconGadget

Posted: Sat Nov 20, 2021 8:41 pm
by Paul
SetGadgetState() ?

example: to select last item in list...

Code: Select all

totalitems=CountGadgetItems(1)
SetGadgetState(1,totalitems-1)  ; -1 is used since index starts at 0

Re: Setting focus on ListIconGadget

Posted: Sun Nov 21, 2021 9:45 am
by firace
Unfortunately this doesn't solve my issue. It does show a row as selected, but the list still does not have keyboard focus - ie, I need to first click on a row before being able to use the up/down arrow keys on my keyboard for navigation.

Re: Setting focus on ListIconGadget

Posted: Sun Nov 21, 2021 11:55 am
by Peter
try this:

Code: Select all

Define GID = GadgetID(1)

! v_gid.gadget.on('dgrid-refresh-complete', function (event) {
!   v_gid.gadget.focus();
! });

Re: Setting focus on ListIconGadget

Posted: Sun Nov 21, 2021 12:20 pm
by firace
That's awesome, thanks Peter!!

Now that got me thinking, perhaps with a variant of this hack, we can find a quick fix to make the ListIconGadget work with IE11 (PB's webgadget)?
I'm referring to the issue mentioned here: viewtopic.php?p=5036#p5036

I will think a little bit about it, as it would be cool... (To be honest I don't feel like waiting for an upgraded webgadget indefinitely)

Re: Setting focus on ListIconGadget

Posted: Mon Nov 22, 2021 3:28 pm
by Dirk Geppert
Peter wrote: Sun Nov 21, 2021 11:55 am try this: [..]
Good to know! Thx Peter!

Re: Setting focus on ListIconGadget

Posted: Mon Nov 22, 2021 3:30 pm
by Peter
firace wrote: Sun Nov 21, 2021 12:20 pmI will think a little bit about it, as it would be cool...
I wish you every success with your project. Personally, it would be too much work for me to run a SpiderBasic app with the IE WebGadget.

Re: Setting focus on ListIconGadget

Posted: Thu Nov 25, 2021 1:42 pm
by firace
This appears to fix the ListIconGadget issue with IE11 / WebGadget - can anyone confirm?

https://www.radsix.com/test21/test111.html

If confirmed I will post the code.

Re: Setting focus on ListIconGadget

Posted: Thu Nov 25, 2021 7:20 pm
by Peter
PureBasic-Code:

Code: Select all

If OpenWindow(0, 0, 0, 800, 800, "WebGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  WebGadget(0, 0, 0, 800, 800, "https://www.radsix.com/test21/test111.html")
  Repeat
  Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
When I run the code above, I get a lot of script error messages and your website does not load correctly.

Only after I have called the BrowserEmulation to set the latest IE version (PureBasic code below), the page can be called. Then navigation via the keyboard also works.

Code: Select all

Procedure SetBrowserEmulation()
  
  ; https://msdn.microsoft.com/en-us/library/ee330730(v=vs.85).aspx
  
  Protected IEVersion.s = "2AF9" ; setting the desired IE-Version (see below)
  
  ; 11001 (0x2AF9) IE11. Webpages are displayed in IE11 edge mode, regardless of the declared !DOCTYPE directive. Failing to declare a !DOCTYPE directive causes the page to load in Quirks.
  ; 11000 (0x2AF8) IE11. Webpages containing standards-based !DOCTYPE directives are displayed in IE11 edge mode. Default value for IE11.
  ; 10001 (0x2711) IE10. Webpages are displayed in IE10 Standards mode, regardless of the !DOCTYPE directive.
  ; 10000 (0x2710) IE10. Webpages containing standards-based !DOCTYPE directives are displayed in IE10 Standards mode. Default value for IE 10.
  ;  9999 (0x270F) IE9.  Webpages are displayed in IE9 Standards mode, regardless of the declared !DOCTYPE directive. Failing to declare a !DOCTYPE directive causes the page to load in Quirks.
  ;  9000 (0x2328) IE9.  Webpages containing standards-based !DOCTYPE directives are displayed in IE9 mode. Default value for IE 9. Important  In IE 10, Webpages containing standards-based !DOCTYPE directives are displayed in IE10 Standards mode.
  ;  8888 (0x22B8) IE8.  Webpages are displayed in IE8 Standards mode, regardless of the declared !DOCTYPE directive. Failing to declare a !DOCTYPE directive causes the page to load in Quirks.
  ;  8000 (0x1F40) IE8.  Webpages containing standards-based !DOCTYPE directives are displayed in IE8 mode. Default value for IE 8 Important  In IE 10, Webpages containing standards-based !DOCTYPE directives are displayed in IE10 Standards mode.
  ;  7000 (0x1B58) IE7.  Webpages containing standards-based !DOCTYPE directives are displayed in IE7 Standards mode. Default value for applications hosting the WebBrowser Control.  
  
  Protected RegistryString.s
  Protected TempRegFile.s
  Protected FF
  
  RegistryString = "Windows Registry Editor Version 5.00" + #CRLF$ +
                   "" + #CRLF$ +
                   "[HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION]" + #CRLF$ +
                   Chr(34) + GetFilePart(ProgramFilename()) + Chr(34) + "=dword:" + IEVersion + #CRLF$
  
  TempRegFile = GetTemporaryDirectory() + "SetBrowserEmulation.reg"
  
  FF = CreateFile(#PB_Any, TempRegFile)
  
  If FF
    WriteString(FF, RegistryString)
    CloseFile(FF)
    RunProgram("regedit", "/s " + Chr(34) + TempRegFile + Chr(34), "", #PB_Program_Hide | #PB_Program_Wait)
    DeleteFile(TempRegFile)
    ProcedureReturn #True
  EndIf
  
EndProcedure

Re: Setting focus on ListIconGadget

Posted: Fri Nov 26, 2021 10:14 am
by plouf
firace wrote: Thu Nov 25, 2021 1:42 pm This appears to fix the ListIconGadget issue with IE11 / WebGadget - can anyone confirm?

https://www.radsix.com/test21/test111.html

If confirmed I will post the code.
Why "fix" to ancient IE11 Since pb has a working workaround to make chromium webgadget