Project

General

Profile

Actions

Bug #3815

closed

WTableView Item CheckBox TriState does not work

Added by Stefan Ruppert over 9 years ago. Updated about 9 years ago.

Status:
Closed
Priority:
High
Assignee:
Benoit Daccache
Target version:
Start date:
02/23/2015
Due date:
% Done:

0%

Estimated time:

Description

Hi,

I'm currently implementing a custom WAbstractItemModel which is used by a WTableView object. The model supports Item checkboxes with TriState flag set to true. However the Wt::PartiallyChecked state is not used at all. It toggles only between Wt::Unchecked and Wt::Checked!?

It seems to me that the checkbox of the WItemDelegate does not provide the Wt::PartiallyChecked state to the model using setData(CheckStateRole)?

Any idea whats going wrong here?

Attached is a simply test application.

Regards,

Stefan


Files

TableCheckBox.cc (5.06 KB) TableCheckBox.cc test application Stefan Ruppert, 02/23/2015 01:21 PM
Actions #1

Updated by Stefan Ruppert over 9 years ago

I use currently wt-3.3.2.

Actions #2

Updated by Koen Deforche over 9 years ago

Hey,

A tristate checkbox will indeed toggle only between checked and unchecked. The partially checked state can only be set through the API. Asfaik this is consistent with what other APIs do, and seems useful in several occasions, but thus not for your use? What behavior are you looking for?

Koen

Actions #3

Updated by Koen Deforche over 9 years ago

  • Status changed from New to Feedback
  • Assignee set to Koen Deforche
Actions #4

Updated by Alan Finley over 9 years ago

Koen Deforche wrote:

Asfaik this is consistent with what other APIs do, and seems useful in several occasions, but thus not for your use?

In Qt you can override that behaviour via virtual method QAbstractButton::nextCheckState

Actions #5

Updated by Stefan Ruppert over 9 years ago

Hi Koen,

Koen Deforche wrote:

A tristate checkbox will indeed toggle only between checked and unchecked. The partially checked state can only be set through the API. Asfaik this is consistent with what other APIs do, and seems useful in several occasions, but thus not for your use? What behavior are you looking for?

>

I have some configuration which can be marked as unused (unchecked), disabled (partially checked) or used (checked). Thus a TriState checkbox perfectly fits here. But the user should be able to select the states. A WAbstractButton::nextCheckState() function would be perfect with the following code:

Wt::CheckState WAbstractButton::nextCheckState()
{
   switch(currentState)
   {
   case Wt::Unchecked:
      return Wt::PartiallyChecked:
   case Wt::PartiallayChecked:
      return Wt::Checked:
   case Wt::Checked:
      return Wt::Unchecked:
   }
}

Maybe add a new NextCheckStateRole which can implement this nextCheckState() functionalitiy?

Actions #6

Updated by Koen Deforche over 9 years ago

Unfortunately, the reason for this seems to be that the native browser implementation of tri-state checkboxes (which is available and used in some browsers, namely the 'indeterminate' state), does not offer this ability. We would of course like to switch to the native support as it becomes available in more browsers.

But I believe the feature could still be implemented using some setting such as 'setCyclePartiallyChecked(true)' which would implement the correct cycling behavior in JavaScript. If you agree to that we can assign it as a feature request for 3.3.4 (or perhaps 3.3.5 because we can't keep on dragging our feet for a release!)

Actions #7

Updated by Stefan Ruppert over 9 years ago

Hi Koen,

yes that is fine for me. Currently I have implemented this with checkboxes in 2 columns. But a working tristate checkbox is preferred from my side.

Regarding a 3.3.4 release: we are planning a new release of our software in april, is there a chance to have a stable 3.3.4 release? We currently use 3.3.2 and I want to jump to a official 3.3.4!

Actions #8

Updated by Koen Deforche over 9 years ago

  • Status changed from Feedback to New
Actions #9

Updated by Koen Deforche over 9 years ago

  • Status changed from New to InProgress
  • Assignee changed from Koen Deforche to Benoit Daccache
  • Target version set to 3.3.5
Actions #10

Updated by Benoit Daccache over 9 years ago

  • Status changed from InProgress to Resolved

Added method WCheckBox::setPartialStateSelectable(bool) which will allow the user to select indeterminate state. This is false by default;

Actions #11

Updated by Koen Deforche about 9 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF