Glen, Jez, Johan,

Thank you for your follow-ups to the original bug report. I've had a quick scout round the other .xs files, and this documentation syntax isn't used elsewhere. I do, however, believe that I can clarify the syntax of the documentation for trackbasr.xs.

The documentation of Win32::GUI::Trackbar::SetPos (from Trackbar.html) says:

SetPos(POSITION,[REDRAW=1])

The XS code looks like this:

###########################################################################
   # (@)METHOD:SetPos(POSITION, [REDRAW=TRUE])
   # Sets the current logical position of the slider in a trackbar.

LRESULT
SetPos(handle, param, value=TRUE)
   HWND   handle
   WPARAM param
   WPARAM value
CODE:
   RETVAL = SendMessage(handle, TBM_SETPOS, value, (LPARAM) param);
OUTPUT:
   RETVAL

The code sets value to TRUE if not supplied, allowing the following 3 ways to call SetPos: (1) $obj->SetPos($pos) - value defaults to 1 and redraw is requested in SendMessage() (2) $obj->SetPos($pos, 1) - value explicitly set to 1 and redraw is requested in SendMessage() (3) $obj->SetPos($pos, 0) - value explicitly set to 0 and redraw is not requested in SendMessage()

There are other examples where similar behaviour happens.

So if we get back to my original bug report on Win32:GUI::Trackbar::Pos(), the documentation says:

Pos([VALUE],[REDRAW=1])

And I firmly believe that this can be interpreted as:
VALUE is optional. It doesn't have a default. (and if not supplied, method returns current position of slider) If VALUE is provided, then an optional second parameter is available, which if not proided defaults to1(true).

The XS code cannot provide a default in this case (due to the optionality of the first argument), and so explicitly looks at the number of arguements. We have 4 ways to call this method, and for consistency with what happens elsewhere this is how I believe the behaviour should be: (1) $obj->Pos() - 0 arguments, return current position (TBM_GETPOS) (2) $obj->Pos($pos) - 1 argument, redraw defaults to 1 and redraw is requested (3) $obj->Pos($pos, 1) - 2 arguments, redraw explicitly set to 1, redraw is requested (4) $obj->Pos($pos, 0) - 2 arguments, redraw explicitly set to 0, redraw is not requested

The "bug" I reported is with option (2), where the current code defaults redraw to 0. For consistency I think this should be changed. Can we reach an agreement on this?

(BTW this 'problem' exists with methods Min(), Max(), Pos(), SelStart(), SelEnd() in trackbar.xs)

Regards,
Rob.

Reply via email to