Page 1 of 1

Suggestions for Clickable TextGadget

Posted: Mon May 12, 2003 10:10 pm
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

Re: Suggestions for Clickable TextGadget

Posted: Sat May 17, 2003 9:26 pm
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

Posted: Sun May 18, 2003 3:56 am
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