Page 1 of 3

AdvancedGadgetEvents() does not exist ?

Posted: Sat Feb 04, 2006 8:26 am
by gnozal
AdvancedGadgetEvents() does not exist anymore.
I did not find anything in the ReadMe about it ?

Code: Select all

OpenWindow(0,0,0,170,106,#PB_Window_ScreenCentered|#PB_Window_SystemMenu,"Button Events")
CreateGadgetList(WindowID(0))
ButtonGadget(1,10,10,150,20,"Links-Klick")
ButtonGadget(2,10,32,150,20,"Rechts-Klick")
ButtonGadget(3,10,54,150,20,"Doppel-Links-Klick")
ButtonGadget(4,10,76,150,20,"Doppel-Rechts-Klick")

Procedure Message()
  MessageRequester("Button "+Str(EventGadget()),GetGadgetText(EventGadget()),0)
EndProcedure

;AdvancedGadgetEvents(#True)

Repeat
  Select WaitWindowEvent()
    Case #PB_Event_CloseWindow: End
    Case #PB_Event_Gadget
      Select EventGadget()
        Case 1
          Select EventType()
            Case #PB_EventType_LeftClick        : Message()
          EndSelect
        Case 2
          Select EventType()
            Case #PB_EventType_RightClick       : Message()
          EndSelect
        Case 3
          Select EventType()
            Case #PB_EventType_LeftDoubleClick  : Message()
          EndSelect
        Case 4
          Select EventType()
            Case #PB_EventType_RightDoubleClick : Message()
          EndSelect
      EndSelect
  EndSelect
ForEver 

Posted: Sat Feb 04, 2006 8:38 am
by Dare2
It has been dropped.

Posted: Sat Feb 04, 2006 8:52 am
by PB
Yep, it only was used to detect right-clicks on ButtonGadgets, therefore it was
removed. I wasn't happy about it either. :( @Freak: Please update the ReadMe.

There'll be workarounds posted for sure, but for now I changed my code to
check if Shift was being held down when a ButtonGadget was clicked, and I
use that instead of a RMB check: If GetAsyncKeyState_(#VK_SHIFT)<>0 ...

Posted: Sat Feb 04, 2006 9:03 am
by gnozal
Dare2 wrote:It has been dropped.
:cry:
Do we have to use a callback now to detect the right-click/double-click events on gadgets ?

Posted: Sat Feb 04, 2006 9:41 am
by Dare2
gnozal wrote:
Dare2 wrote:It has been dropped.
:cry:
Do we have to use a callback now to detect the right-click/double-click events on gadgets ?
Actually, I don't know it that will be the final state of play. PB? Fred?

Posted: Sat Feb 04, 2006 10:27 am
by PB
> Do we have to use a callback now to detect the right-click/double-click events on gadgets ?

No. AdvancedGadgetEvents() was ONLY used for ButtonGadgets.

Right and double-clicks are still detected normally on gadgets that support them:
http://www.purebasic.com/documentation/ ... ttype.html

Posted: Sat Feb 04, 2006 10:35 am
by gnozal
PB wrote:> Do we have to use a callback now to detect the right-click/double-click events on gadgets ?

No. AdvancedGadgetEvents() was ONLY used for ButtonGadgets.

Right and double-clicks are still detected normally on gadgets that support them:
http://www.purebasic.com/documentation/ ... ttype.html
Ok, but why has it been dropped? It was very usefull.

Posted: Sat Feb 04, 2006 10:47 am
by PB
> but why has it been dropped? It was very usefull.

This is what Fred told me (direct quotes):

AdvancedEvents() was just for the button gadget IIRC and it has been
removed, as it was almost useless. [...] We could add this event natively,
but i don't think it's a good idea.


Now, he's got a point: I noticed when I had AdvancedGadgetEvents(#True),
that rapidly clicking on a ButtonGadget would "miss" some events, so it was
probably a bit buggy and useless all along. Setting it to #False made me be
able to click the ButtonGadget quickly again, and respond like a normal app.
So there must have been some hack going on in the background for #True.
And as it was only used for this one type of gadget, it was made obsolete.

Posted: Sat Feb 04, 2006 11:05 am
by gnozal
PB wrote:This is what Fred told me (direct quotes):
AdvancedEvents() was just for the button gadget IIRC and it has been
removed, as it was almost useless. [...] We could add this event natively,
but i don't think it's a good idea.
It was not useless to me, I used it a lot ... I suppose I have to live with it.

Posted: Sat Feb 04, 2006 1:02 pm
by PB
> It was not useless to me, I used it a lot ... I suppose I have to live with it.

Solution here: viewtopic.php?p=123404

:)

Posted: Sat Feb 04, 2006 2:14 pm
by nco2k
i was using AdvancedGadgetEvents() for something like this, so it was very usefull for me... :evil:

Code: Select all

;/ Default-Button Example by nco2k (long time ago)

#Button_A = 0 
#Button_B = 1 
#Button_Exit = 2 

#Shortcut_Escape = 0 
#Shortcut_Return = 1 

Global DefaultButton.l 

Procedure WndProc(hWnd, Msg, wParam, lParam) 
  If Msg = #WM_ACTIVATE 
    If hWnd = WindowID(0) 
      If (wParam & $FFFF) = #WA_INACTIVE 
        SendMessage_(GadgetID(#Button_A), #BM_SETSTYLE, 0, #True) 
        SendMessage_(GadgetID(#Button_B), #BM_SETSTYLE, 0, #True) 
        SendMessage_(GadgetID(#Button_Exit), #BM_SETSTYLE, 0, #True) 
      Else 
        If DefaultButton = #Button_A 
          SendMessage_(GadgetID(#Button_A), #BM_SETSTYLE, #BS_DEFPUSHBUTTON, #True) 
        ElseIf DefaultButton = #Button_B 
          SendMessage_(GadgetID(#Button_B), #BM_SETSTYLE, #BS_DEFPUSHBUTTON, #True) 
        ElseIf DefaultButton = #Button_Exit 
          SendMessage_(GadgetID(#Button_Exit), #BM_SETSTYLE, #BS_DEFPUSHBUTTON, #True) 
        EndIf 
      EndIf 
    EndIf 
  EndIf 
  ProcedureReturn #PB_ProcessPureBasicEvents 
EndProcedure 

If OpenWindow(0, 0, 0, 320, 95, #PB_Window_TitleBar | #PB_Window_SystemMenu | #PB_Window_ScreenCentered, "Default-Button Example") 
  If CreateGadgetList(WindowID(0)) 
    AdvancedGadgetEvents(#True) 
    ButtonGadget(#Button_A, 110, 5, 100, 25, "A") 
    ButtonGadget(#Button_B, 110, 35, 100, 25, "B", #PB_Button_Default) 
    DefaultButton = #Button_B 
    ActivateGadget(#Button_B) 
    ButtonGadget(#Button_Exit, 110, 65, 100, 25, "Exit") 
  EndIf 
  AddKeyboardShortcut(0, #PB_Shortcut_Escape, #Shortcut_Escape) 
  AddKeyboardShortcut(0, #PB_Shortcut_Return, #Shortcut_Return) 
  SetWindowCallback(@WndProc()) 
EndIf 

Repeat 
  Select WaitWindowEvent() 
    Case #PB_Event_Menu 
      Select EventMenuID() 
        Case #Shortcut_Escape 
          End 
        Case #Shortcut_Return 
          If DefaultButton = #Button_A 
            Debug "A" 
          ElseIf DefaultButton = #Button_B 
            Debug "B" 
          ElseIf DefaultButton = #Button_Exit 
            End 
          EndIf 
      EndSelect 
    Case #PB_Event_Gadget 
      Select EventGadgetID() 
        Case #PB_Event_Gadget 
          Case #Button_A 
            Select EventType() 
              Case #PB_EventType_Focus 
                SendMessage_(GadgetID(#Button_B), #BM_SETSTYLE, 0, #True) 
                SendMessage_(GadgetID(#Button_Exit), #BM_SETSTYLE, 0, #True) 
                SendMessage_(GadgetID(#Button_A), #BM_SETSTYLE, #BS_DEFPUSHBUTTON, #True) 
                DefaultButton = #Button_A 
              Case #PB_EventType_LeftClick 
                Debug "A" 
            EndSelect 
          Case #Button_B 
            Select EventType() 
              Case #PB_EventType_Focus 
                SendMessage_(GadgetID(#Button_A), #BM_SETSTYLE, 0, #True) 
                SendMessage_(GadgetID(#Button_Exit), #BM_SETSTYLE, 0, #True) 
                SendMessage_(GadgetID(#Button_B), #BM_SETSTYLE, #BS_DEFPUSHBUTTON, #True) 
                DefaultButton = #Button_B 
              Case #PB_EventType_LeftClick 
                Debug "B" 
            EndSelect 
          Case #Button_Exit 
            Select EventType() 
              Case #PB_EventType_Focus 
                SendMessage_(GadgetID(#Button_A), #BM_SETSTYLE, 0, #True) 
                SendMessage_(GadgetID(#Button_B), #BM_SETSTYLE, 0, #True) 
                SendMessage_(GadgetID(#Button_Exit), #BM_SETSTYLE, #BS_DEFPUSHBUTTON, #True) 
                DefaultButton = #Button_Exit 
              Case #PB_EventType_LeftClick 
                End 
            EndSelect 
      EndSelect 
    Case #PB_Event_CloseWindow 
      End 
  EndSelect 
ForEver 

End
same with MoveWindow() why was that dropped?? now i have to use ResizeWindow(0, 200, 200, WindowWidth(0), WindowHeight(0)) when i only want to change the x/y. :roll:

c ya,
nco2k

Posted: Sat Feb 04, 2006 2:20 pm
by Berikco
nco2k wrote: same with MoveWindow() why was that dropped?? now i have to use ResizeWindow(0, 200, 200, WindowWidth(0), WindowHeight(0)) when i only want to change the x/y. :roll:

Code: Select all

 ResizeWindow(0, 200, 200, -1, -1)

Posted: Sat Feb 04, 2006 2:27 pm
by nco2k
@Berikco
ok thanks, but if i only want to resize the window, ResizeWindow(0, -1, -1, 600, 500) should change the position of x/y to -1, so i have to use ResizeWindow(0, WindowX(0), WindowY(0), 600, 500). imo it would be better to keep ResizeWindow() and MoveWindow() seperated and put a optional flag for MoveWindow() to set the window screen centered.

c ya,
nco2k

Posted: Sat Feb 04, 2006 2:31 pm
by PB
> ResizeWindow(0, -1, -1, 600, 500) should change the position of x/y to -1

Excellent point! :shock:

@Fred: What happens if we actually do want to position a window at -1,-1?

Posted: Sat Feb 04, 2006 2:38 pm
by freak
ResizeGadget() also uses -1 to keep the old position, and nobody ever had a problem with that,
why should it be a problem with ResizeWindow() ?