It is currently Thu Nov 23, 2017 12:06 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Programmatically applied mouse click
PostPosted: Sun Jun 18, 2017 12:05 am 
Offline
Always Here
Always Here

Joined: Fri Oct 23, 2009 2:33 am
Posts: 5687
Location: Wales, UK
PB 5.60 x86 Win7 x86
If the User mouse-clicks a ListIcon row to select it, that row is highlighted (#COLOR_HIGHLIGHT). If the row is selected programmatically using SetGadgetState(MyList, MyRow), the row is not highlighted.

Is there a simple way to send a mouse click to a specific row to get that highlighting?

_________________
IdeasVacuum
If it sounds simple, you have not grasped the complexity.


Top
 Profile  
Reply with quote  
 Post subject: Re: Programmatically applied mouse click
PostPosted: Sun Jun 18, 2017 3:44 am 
Offline
Addict
Addict

Joined: Sun Apr 12, 2009 6:27 am
Posts: 2844
Hi
No need for simulating mouse click
Code:
Procedure selectrow(gadget,index)
  Row_H = SendMessage_(GadgetID(gadget), #LVM_GETITEMSPACING, 1, 0) >> 16
 SendMessage_(GadgetID(0), #LVM_SCROLL, 0,-CountGadgetItems(gadget)*Row_H)
  SetGadgetItemState(gadget,index,#PB_ListIcon_Selected)
  SetActiveGadget(gadget) 
  SendMessage_(GadgetID(0), #LVM_SCROLL, 0,index*Row_H)
EndProcedure

LoadFont(0,"Arial",12)
If OpenWindow(0, 0, 0, 640, 350, "ListIconGadgets", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
    ListIconGadget(0,  10,  10, 620, 280, "Column 0", 400,#PB_ListIcon_GridLines|#PB_ListIcon_FullRowSelect| #PB_ListIcon_AlwaysShowSelection)
    SetGadgetFont(0,FontID(0))
    AddGadgetColumn(0, 1, "Column 1" , 200)
    For x = 0 To 100
      AddGadgetItem(0, x, "Item "+Str(x)+Chr(10)+"Item "+Str(x))
    Next
   
    ButtonGadget(1,10,310,80,20,"TEST")
EndIf
Repeat
  Select WaitWindowEvent()
    Case #PB_Event_CloseWindow
      Quit = 1
     
    Case #PB_Event_Gadget
      Select EventGadget()
        Case 1
          If run = 0
            run = 1
            selectrow(0,2)
          ElseIf run = 1
            run = 2
            selectrow(0,15)
          ElseIf run = 2
            selectrow(0,4)
          EndIf
      EndSelect
  EndSelect
 
Until Quit = 1


But if it is required
Code:
Procedure Selectrow(gadget,index)
  r.RECT
  Cell.LVHITTESTINFO
  Cell\iItem       = index
  r\left = #LVIR_BOUNDS
  SendMessage_(GadgetID(gadget), #LVM_GETSUBITEMRECT, Cell\iItem, r)
  MapWindowPoints_(GadgetID(0),0,r,1)
  SetCursorPos_(r\left+10,r\top+10)
  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

LoadFont(0,"Arial",12)
If OpenWindow(0, 0, 0, 640, 300, "ListIconGadgets", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
    ListIconGadget(0,  10,  10, 620, 280, "Column 0", 400,#PB_ListIcon_GridLines|#PB_ListIcon_FullRowSelect| #PB_ListIcon_AlwaysShowSelection)
    SetGadgetFont(0,FontID(0))
    AddGadgetColumn(0, 1, "Column 1" , 200)
    For x = 0 To 100
      AddGadgetItem(0, x, "Item "+Str(x)+Chr(10)+"Item "+Str(x))
    Next 
 
  Selectrow(0,2)
EndIf
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow

_________________
Egypt my love


Top
 Profile  
Reply with quote  
 Post subject: Re: Programmatically applied mouse click
PostPosted: Sun Jun 18, 2017 2:24 pm 
Offline
Always Here
Always Here

Joined: Fri Oct 23, 2009 2:33 am
Posts: 5687
Location: Wales, UK
Hi Rashad :D

Thanks for that very quick help - the difference was actually made by SetActiveGadget(MyListIcon) :oops:

_________________
IdeasVacuum
If it sounds simple, you have not grasped the complexity.


Top
 Profile  
Reply with quote  
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 1 guest


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