AdvancedGadgetEvents() does not exist ?

Just starting out? Need help? Post your questions and find answers here.
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

AdvancedGadgetEvents() does not exist ?

Post 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 
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
Dare2
Moderator
Moderator
Posts: 3321
Joined: Sat Dec 27, 2003 3:55 am
Location: Great Southern Land

Post by Dare2 »

It has been dropped.
@}--`--,-- A rose by any other name ..
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post 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 ...
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post 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 ?
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
Dare2
Moderator
Moderator
Posts: 3321
Joined: Sat Dec 27, 2003 3:55 am
Location: Great Southern Land

Post 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?
@}--`--,-- A rose by any other name ..
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post 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
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post 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.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post 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.
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post 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.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post 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

:)
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
User avatar
nco2k
Addict
Addict
Posts: 1344
Joined: Mon Sep 15, 2003 5:55 am

Post 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
If OSVersion() = #PB_OS_Windows_ME : End : EndIf
Berikco
Administrator
Administrator
Posts: 1326
Joined: Wed Apr 23, 2003 7:57 pm
Location: Belgium
Contact:

Post 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)
User avatar
nco2k
Addict
Addict
Posts: 1344
Joined: Mon Sep 15, 2003 5:55 am

Post 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
If OSVersion() = #PB_OS_Windows_ME : End : EndIf
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post 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?
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
freak
PureBasic Team
PureBasic Team
Posts: 5940
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Post 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() ?
quidquid Latine dictum sit altum videtur
Post Reply