It is currently Fri May 24, 2013 11:44 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Right-Click on PanelGadget tabs
PostPosted: Sun Apr 22, 2012 5:49 pm 
Offline
Enthusiast
Enthusiast

Joined: Tue Nov 09, 2010 10:15 pm
Posts: 794
Is there an easy way to catch a right-click on a panelgadget tab to change the tab?

On the PB IDE, if you right-click on a tab that is not active, it gets focus before bringing up the popup menu.

With standard, simple message processing, if you right-click on a tab, nothing happens. You don't even get a panelgadget event. So, is the way to do that to capture the right-clicks, calculate the mouse tab it is over based on the text size and number of characters in the tab text, set focus on the tab, then display the popup?

This just seems extremely laborious, and I'm trying to figure out if there is a simpler way. Thanks a lot!


Top
 Profile  
 
 Post subject: Re: Right-Click on PanelGadget tabs
PostPosted: Sun Apr 22, 2012 7:20 pm 
Offline
Addict
Addict

Joined: Sun Apr 12, 2009 6:27 am
Posts: 1473
Code:
 Procedure LeftClick ()
  In.INPUT
  In\type        = #INPUT_MOUSE
  In\mi\dwFlags  = #MOUSEEVENTF_LEFTDOWN
  SendInput_(1,@In,SizeOf(INPUT))
  In\mi\dwFlags  = #MOUSEEVENTF_LEFTUP
  SendInput_(1,@In,SizeOf(INPUT))
EndProcedure

  If OpenWindow(0, 0, 0, 322, 220, "PanelGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
    PanelGadget     (0, 8, 8, 306, 203)
      AddGadgetItem (0, -1, "Panel 1")
        PanelGadget (1, 5, 5, 290, 166)
          AddGadgetItem(1, -1, "Sub-Panel 1")
          AddGadgetItem(1, -1, "Sub-Panel 2")
          AddGadgetItem(1, -1, "Sub-Panel 3")
        CloseGadgetList()
      AddGadgetItem (0, -1,"Panel 2")
        ButtonGadget(2, 10, 15, 80, 24,"Button 1")
        ButtonGadget(3, 95, 15, 80, 24,"Button 2")
    CloseGadgetList()
Repeat
  Select WaitWindowEvent()
     
      Case #PB_Event_CloseWindow
            Quit = 1           

      Case #WM_RBUTTONDOWN
            LeftClick ()
            Debug "Right Button Clicked"
             
  EndSelect
  Until Quit = 1
  EndIf



Detect Right Click on Tabs

Code:
 Procedure LeftClick ()
  In.INPUT
  In\type        = #INPUT_MOUSE
  In\mi\dwFlags  = #MOUSEEVENTF_LEFTDOWN
  SendInput_(1,@In,SizeOf(INPUT))
  In\mi\dwFlags  = #MOUSEEVENTF_LEFTUP
  SendInput_(1,@In,SizeOf(INPUT))
EndProcedure

  If OpenWindow(0, 0, 0, 322, 220, "PanelGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
    PanelGadget     (0, 8, 8, 306, 203)
      AddGadgetItem (0, -1, "Panel 1")
        PanelGadget (1, 5, 5, 290, 166)
          AddGadgetItem(1, -1, "Sub-Panel 1")
          AddGadgetItem(1, -1, "Sub-Panel 2")
          AddGadgetItem(1, -1, "Sub-Panel 3")
        CloseGadgetList()
      AddGadgetItem (0, -1,"Panel 2")
        ButtonGadget(2, 10, 15, 80, 24,"Button 1")
        ButtonGadget(3, 95, 15, 80, 24,"Button 2")
    CloseGadgetList()
Repeat
  Select WaitWindowEvent()
     
      Case #PB_Event_CloseWindow
            Quit = 1           
           
      Case #WM_RBUTTONDOWN
               State_0 = GetGadgetState(0)
               State_1 = GetGadgetState(1)
               LeftClick ()
               
      Case #WM_RBUTTONUP
              If (GetGadgetState(0) <> State_0) Or (GetGadgetState(1) <> State_1)
                  Debug "Right Button Clicked"
              EndIf
;             
  EndSelect
  Until Quit = 1
  EndIf


_________________
Egypt my love


Top
 Profile  
 
 Post subject: Re: Right-Click on PanelGadget tabs
PostPosted: Sun Apr 22, 2012 9:03 pm 
Offline
Enthusiast
Enthusiast

Joined: Tue Nov 09, 2010 10:15 pm
Posts: 794
Rashad,
Thank you for the code. I had to rename IN.INPUT to avoid choking the assembler.

Is there a cross-platform solution? I would like this to work with Linux & Mac, too.

Thanks again!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye