Forum Discussion

finae's avatar
finae
Contributor
9 years ago
Solved

Ultrabutton and VK_LControl/VK_RControl

Hi,

 

   Just want to know if anyone has run into this problem.

 

   here's a portion of the logic thats driving me up the wall.

 

  

function SelectRows(grid,rowidxes)
    set grid.activerow=nothing         'remove all active rows
    grid.selected.rows.clear     'clear all selected rows
   
   idxes=split(rowidxes,",")
    if ubound(idxes)>0 then 
          grid.rows.item(cint(rowidxes(0)-1).set_selected(true) 'set the first row to be selected
          
           Sys.Desktop.Keydown(Win32api.VK_LCONROL) 'hold down control
          for each ri in idxes
                if cint(ri)>grid.rows.count then 
                      log.warning "row idx is higher than total rows avaialble"
                else
                      grid.rows.item(cint(ri)-1).set_selected(true)  'select next row
                end if
          next
         Sys.Desktop.KeyUp(Win32APi.VK_LControl)  'release the Lcontrol key
    end if

end function

my problem is after its supposely has release teh control, clicking the OK button does not do anything.

though if i do it manually holding the lcontrol , select a few iem and then release it, it  did nto have aproblem.

So i m kind of stuck on how to 'release' the key so that i can click on teh button directly

 

Thanks

  • Hi,

     

    The reason of the problem is that you are mixing two approaches and they do not work together. You are trying to multi-select grid rows by pressing the Control key (end-user action) and then call some grid's internal method (.set_selected() - non end-user action). Most probably, .set_selected() does not do something (set some property, call some method, etc.) that is used by the code that is called on OK button press.

    I would recommend to search/check how to click the needed row (it might be something like grid.rows.item(cint(ri)-1).Click) and replace the line with the call to the .set_selected() method with the line(s) that perform a click on the row.

    If you fail to find how to click grid's row, then you should examine the list of available grid's methods more carefully - maybe you'll need to call some other method or call two or more methods.

    Also, you may search TestComplete's help and samples, as well as this forum for the name/class name of the grid you are working with - there is a chance that you will find a relevant code sample.

3 Replies

  • AlexKaras's avatar
    AlexKaras
    Champion Level 3

    Hi,

     

    The reason of the problem is that you are mixing two approaches and they do not work together. You are trying to multi-select grid rows by pressing the Control key (end-user action) and then call some grid's internal method (.set_selected() - non end-user action). Most probably, .set_selected() does not do something (set some property, call some method, etc.) that is used by the code that is called on OK button press.

    I would recommend to search/check how to click the needed row (it might be something like grid.rows.item(cint(ri)-1).Click) and replace the line with the call to the .set_selected() method with the line(s) that perform a click on the row.

    If you fail to find how to click grid's row, then you should examine the list of available grid's methods more carefully - maybe you'll need to call some other method or call two or more methods.

    Also, you may search TestComplete's help and samples, as well as this forum for the name/class name of the grid you are working with - there is a chance that you will find a relevant code sample.

    • finae's avatar
      finae
      Contributor

      Thanks for the suggsetion, that was the only way i can get about it.

       

      Currently it is still using Set_Select(true) as the command to select the rows since its part of the function that is being used most of the grid related activities. In the future it can be updated but for now it will have to retain.

       

      I had to get teh x/y location using Accessibility object of the cell using an existing valid row's cell and then using LLPLayer to move and click while control is hold down, basically reclicking to select the row. This fix the issue with the Ultrabutton now working as it normally is suppose to.

       

      As per your guess, the set_select() automatically select the rows, but as there's no onclick action on the grid's row, and that could likely be the control that prevent the Ultrabutton's OnClick event' to not kick in place.

      • AlexKaras's avatar
        AlexKaras
        Champion Level 3

        Hi,

         

        Great to know that you solved the problem.

        I hoped that it is possible to identify and click the row without the use of MSAA (as I suspect that it might slow-down test speed), but if it works for you, the solution with MSAA and LLPlayer looks perfectly well.

         

        And yes, the absence of OnClick event well might be the reason of why the button did not work initially.