I have read what the reference has to offer on them and it doesn't mean very much to me given my lack of knowledge.
I have been trying to learn from experience, to get an action to occur during a leftclick for example.
I have this, code, that some others were adding to, but I can use it to highlight one of my problems.
I can't see why
Code: Select all
Select EventType()
Case #PB_EventType_LeftClick : Debug "Click with left mouse button"
EndSelect
Code: Select all
Case #PB_EventType_LeftClick
Code: Select all
: Debug "Click with left mouse button"
Is there a way to give a unique Case number to #PB_EventType_LeftClick, like the
Code: Select all
AddKeyboardShortcut(0,#PB_Shortcut_Space,10)
AddKeyboardShortcut(0,#PB_Shortcut_Add,20)
Here is the full code i'm talking about.
Code: Select all
EnableExplicit
Enumeration
#InputString
#ConvertButton
#ResultString
#InputText
#ResultText
#TextGadget
EndEnumeration
Define Event.i, Exit.i, Input$
OpenWindow(0, 0, 0, 220, 100, "Inch To cm", #PB_Window_SystemMenu|#PB_Window_ScreenCentered)
InitKeyboard()
TextGadget(#InputText, 10, 10, 60, 20, "Input")
TextGadget(#ResultText, 150, 10, 60, 20, "Result")
StringGadget(#InputString, 10, 40, 60, 20, "0" ,#PB_String_Numeric)
ButtonGadget(#ConvertButton, 80, 40, 60, 20, "Convert")
StringGadget(#ResultString, 150, 40, 60, 20, "0")
TextGadget(#TextGadget,10,70,200,20,"Gadget : "+Str(GetActiveGadget())+" has the focus")
AddKeyboardShortcut(0,#PB_Shortcut_Space,10)
AddKeyboardShortcut(0,#PB_Shortcut_Add,20)
AddWindowTimer(0,10,100)
Repeat
Event = WaitWindowEvent()
Select EventType()
Case #PB_EventType_LeftClick : Debug "Click with left mouse button"
EndSelect
Select Event
Case #PB_Event_Timer
SetGadgetText(#TextGadget,"Gadget : "+Str(GetActiveGadget())+" has the focus")
Case #PB_Event_Menu
Select EventMenu()
Case 10
If GetActiveGadget() = #InputString
SetGadgetText(#ResultString, StrF(ValD(GetGadgetText(#InputString)) * 2.54, 3))
EndIf
Case 20
If GetActiveGadget() = #ResultString
SetActiveGadget(#InputString)
Else
SetActiveGadget(GetActiveGadget()+1)
EndIf
EndSelect
Case #PB_Event_Gadget
Select EventGadget()
Case #InputString
Input$ = GetGadgetText(#InputString)
If Input$ = ""
DisableGadget(#ConvertButton, #True)
Else
DisableGadget(#ConvertButton, #False)
EndIf
Case #ConvertButton
SetGadgetText(#ResultString, StrF(ValD(GetGadgetText(#InputString)) * 2.54, 3))
EndSelect
Case #PB_Event_CloseWindow
Exit = #True
EndSelect
Until Exit