Suggestions for Clickable TextGadget

Everything else that doesn't fall into one of the other PB categories.
ebs
Enthusiast
Enthusiast
Posts: 561
Joined: Fri Apr 25, 2003 11:08 pm

Suggestions for Clickable TextGadget

Post by ebs »

I'm looking for suggestions on how to make a gadget containing the letters A-Z, which would provide an event to indicate which letter has been clicked on.

Standard TextGadgets don't give PB events, so maybe using a callback routine? Also, I would prefer to use just one gadget, not 26 separate ones, if possible.

Is there a way to create a sort of "image map"? It would give an event when clicked, and have an simple way to get the mouse coordinates to determine which letter was clicked.

Thanks for any help,
Eric
FloHimself
Enthusiast
Enthusiast
Posts: 229
Joined: Wed May 14, 2003 3:38 pm
Location: Lüneburg - Germany

Re: Suggestions for Clickable TextGadget

Post by FloHimself »

Hello Eric,

i know it's not really what you've searching for, but maybe a simple workaround...

Code: Select all

#BS_FLAT = $8000

#Window_0 = 0

#Char_Gadget_Base = 65

Procedure Open_Window_0()
  If OpenWindow(#Window_0, 271, 72, 495, 50,  #PB_Window_SystemMenu | #PB_Window_TitleBar, "Char Button Test")
    If CreateGadgetList(WindowID())
      For i = 0 To 25
        ButtonGadget(#Char_Gadget_Base + i, i * 19, 10, 20, 20, Chr(65 + i), #BS_FLAT) 
      Next
    EndIf
  EndIf
EndProcedure


Open_Window_0()

Repeat
  Event = WaitWindowEvent()
    Select Event 
      Case #PB_EventGadget
          For i = 0 To 25
            If EventGadgetID() = #Char_Gadget_Base + i
              MessageRequester("Pressed Char:", Chr(#Char_Gadget_Base + i), 0)
            EndIf
          Next
    EndSelect
Until Event = #PB_EventCloseWindow
End
ebs
Enthusiast
Enthusiast
Posts: 561
Joined: Fri Apr 25, 2003 11:08 pm

Post by ebs »

Thanks for the suggestion, but I rethought what I wanted. I used groups of three letters instead of individual letters. This got the items needed down to a more manageable number - 9 instead of 26. This let me use a very short PanelGadget, which works pretty well.

Thanks again,
Eric
Post Reply