← Back to team overview

sikuli-driver team mailing list archive

[Bug 1450805] Re: [1.0.1] Allow click() to accept and ignore 'None' as a modifier --- fixed 2015-05-02+

 

good point, since the modifiers in future (already available with type()) should be strings anyway.
So I just changed the API at the Java level from int to Integer, which now allows to use None at the script level.

BTW: 
--- since that is usually the default behavior of an optional argument
... might be true for the Jython scripting level, but since the Region API is completely implemented at the Java level, this is not really true here (Java does not have keyword nor optional args yet.

--- since you have a wrapper anyway, this would have been your private
solution ;-)

def myClickFun(region, image, modifier=None):
    # Do some things for stability
    region.click(image, modifier ? modifier : 0)

-- 
You received this bug notification because you are a member of Sikuli
Drivers, which is subscribed to Sikuli.
https://bugs.launchpad.net/bugs/1450805

Title:
  [1.0.1] Allow click() to accept and ignore 'None' as a modifier ---
  fixed 2015-05-02+

Status in Sikuli:
  Fix Committed

Bug description:
  Currently the click() method accepts key modifiers as optional arguments. We have created a wrapper function on the click to ensure a little extra stability with the click method and have it available across all scripts.
  ex:

  def myClickFun(region, image, modifier=None):
      # Do some things for stability
      region.click(image, modifier)

  We ran into an issue when we needed to introduce the key modifier
  argument. If we provide the modifier it works as expected, however
  this breaks all other instances where no modifier is provided giving
  the following error:

  TypeError: click(): 2nd arg can't be coerced to int

  I was expecting the None to be ignored since that is usually the
  default behavior of an optional argument. Then I remembered that you
  can supply an integer with the click() method (A quick test revealed
  that no integer and a value of 60 timed out at about the same time).
  It seems that the click method could accept keyword arguments (and
  ignore none as a modifier) to allow for greater flexibility in the
  method call. Maybe just a single keyword for the modifier in case an
  integer is not supplied?

  I realize the great chance that I'm doing something wrong here... if
  so please let me know.

To manage notifications about this bug go to:
https://bugs.launchpad.net/sikuli/+bug/1450805/+subscriptions


References