Page 1 of 1

icon and text overlapping when accessibility setting is activated

Posted: Sun Dec 15, 2024 2:20 pm
by breeze4me
When accessibility setting is turned on, icon and text appear overlapping.
Example of the Procedure Browser panel. (PB 6.20 b1 on Windows 10)
Image

A related reply.
viewtopic.php?p=632217#p632217

Re: icon and text overlapping when accessibility setting is activated

Posted: Sun Dec 15, 2024 3:19 pm
by Quin
The text is needed for screen readers, but I'm really not sure if there's a better way. I was told that calling SetGadgetText() doesn't even show the text...guess that was incorrect and we may need to call out to underlying accessibility APIs.
I did open a feature request about this, just FYI.

Re: icon and text overlapping when accessibility setting is activated

Posted: Sun Dec 15, 2024 3:25 pm
by breeze4me
Quin wrote: Sun Dec 15, 2024 3:19 pm The text is needed for screen readers, but I'm really not sure if there's a better way. I was told that calling SetGadgetText() doesn't even show the text...guess that was incorrect and we may need to call out to underlying accessibility APIs.
I did open a feature request about this, just FYI.
When you run this code, can your screen reader program read the button text?

Code: Select all

If OpenWindow(0, 0, 0, 200, 60, "ButtonImageGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  If LoadImage(0,  #PB_Compiler_Home + "examples/sources/Data/CDPlayer.ico")
    hwnd = ButtonGadget(0, 10, 10, 180, 40, "This text shows over the image :(", #BS_ICON)
    SendMessage_(hwnd, #BM_SETIMAGE, #IMAGE_ICON, ImageID(0))
  EndIf
  Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf

Re: icon and text overlapping when accessibility setting is activated

Posted: Sun Dec 15, 2024 4:13 pm
by Quin
breeze4me wrote: Sun Dec 15, 2024 3:25 pm
Quin wrote: Sun Dec 15, 2024 3:19 pm The text is needed for screen readers, but I'm really not sure if there's a better way. I was told that calling SetGadgetText() doesn't even show the text...guess that was incorrect and we may need to call out to underlying accessibility APIs.
I did open a feature request about this, just FYI.
When you run this code, can your screen reader program read the button text?

Code: Select all

If OpenWindow(0, 0, 0, 200, 60, "ButtonImageGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  If LoadImage(0,  #PB_Compiler_Home + "examples/sources/Data/CDPlayer.ico")
    hwnd = ButtonGadget(0, 10, 10, 180, 40, "This text shows over the image :(", #BS_ICON)
    SendMessage_(hwnd, #BM_SETIMAGE, #IMAGE_ICON, ImageID(0))
  EndIf
  Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
Yes, it can. I run it and press tab and hear: "This text shows over the image :( button" exactly as I'd expect.

Re: icon and text overlapping when accessibility setting is activated

Posted: Mon Dec 16, 2024 3:42 pm
by breeze4me
I've tested it by replacing the ButtonImageGadget with a ButtonGadget in the three files below, and it seems to work pretty much as it should, except that I have to force the return result of the GetRequiredSize() function to be specified.
Instead of the #BS_ICON and #IMAGE_ICON constants, the #BS_BITMAP and #IMAGE_BITMAP constants should be used.

Code: Select all

ProcedureBrowser.pb
Issues.pb
CompilerOptions.pb

Code: Select all

    CompilerIf #CompileWindows
      Space = 3
      Width = 28
      Height = 28
    CompilerElse
      Space = 6 ; looks better on Linux/OSX with some more space
    CompilerEndIf
The CompilerOptions.xml file also needs to modify "buttonimage" to "button", which doesn't look good because it automatically changes the width of the button to the width of the hidden string.

Code: Select all

              <buttonimage id="#GADGET_Option_AddTarget" />
              <buttonimage id="#GADGET_Option_CopyTarget" />
              <buttonimage id="#GADGET_Option_EditTarget" />
              <buttonimage id="#GADGET_Option_RemoveTarget" />
              <buttonimage id="#GADGET_Option_TargetUp" />
              <buttonimage id="#GADGET_Option_TargetDown" />
Anyway, for the reason mentioned above, the two files CompilerOptions.pb and CompilerOptions.xml are optional.
https://www.dropbox.com/scl/fi/1dexl9r4 ... 4oj0f&dl=0

Edit:
It would be better to use a 1x1 dummy image, as shown below.

Code: Select all

If OpenWindow(0, 0, 0, 200, 60, "ButtonImageGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  If LoadImage(0,  #PB_Compiler_Home + "examples/sources/Data/CDPlayer.ico")
    hwnd = ButtonImageGadget(0, 10, 10, 180, 40, ImageID(0), #BS_BITMAP)
    
    ; set a dummy image.
    CreateImage(1, 1, 1, 24, GetSysColor_(#COLOR_BTNFACE))
    SendMessage_(hwnd, #BM_SETIMAGE, #IMAGE_BITMAP, ImageID(1))
    
    SetGadgetText(0, "This text shows over the image :(")
  EndIf
  Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
The files modified to use the trick above. Without the above files, only these 4 modified files are needed.

Code: Select all

Common.pb
CompilerOptions.pb
Issues.pb
ProcedureBrowser.pb
https://www.dropbox.com/scl/fi/2oykvkc8 ... qpehl&dl=0