Jump to content


Photo

New TUniCheckListBox component

TUniCheckListBox

  • Please log in to reply
30 replies to this topic

#1 arilotta

arilotta

    Advanced Member

  • uniGUI Subscriber
  • PipPipPipPip
  • 105 posts
  • LocationTrieste, Italy

Posted 28 August 2017 - 01:29 PM

 
Hi, 
 
this is my first UniGui component: TUniCheckListBox. It resembles the classic VCL component TCheckListBox,
a component that I was familiar with, and that I found was missing from the UniGUI included components.
 
First of all, I would like to thank Delphi Developer, because the main code used in the component was supplied
by him in the following post:
 
 
The component is based on TUniCustomListBox, and its usage is therefore very similar to TUniListBox.
The items in the list can only be multi-selected using the checkbox, rather then the using the left
mouse button click in combination with Ctrl/Shift keys.
 
To install it, just open the UniCustomComponents package, change the Delphi version in the UniCustomComponents package source
(I used UniGUI23 for Delphi 10 Seattle); it should be UniGUI24 for Berlin and UniGUI25 for Tokio....
Then build and install the package.
 
Thanks
 
Andrea Arilotta
 

Attached Files


  • 3

#2 bbosnjak

bbosnjak

    Active Member

  • uniGUI Subscriber
  • PipPipPip
  • 59 posts

Posted 28 August 2017 - 01:39 PM

Thanks for sharing!

Sent from my SM-P900 using Tapatalk
  • 0

#3 Delphi Developer

Delphi Developer

    Advanced Member

  • Moderators
  • 5179 posts

Posted 28 August 2017 - 01:40 PM

Thanks for sharing!
  • 0

#4 _Mehmet_

_Mehmet_

    Advanced Member

  • uniGUI Subscriber
  • PipPipPipPip
  • 515 posts
  • LocationAntalya / Turkey

Posted 29 August 2017 - 06:36 AM

Thanks arilotta


  • 0

#5 mos

mos

    Advanced Member

  • uniGUI Subscriber
  • PipPipPipPip
  • 167 posts

Posted 31 January 2018 - 07:21 AM

I am trying to build and install this component for XE2 but am getting errors in the following line of code:

JSInterface.JSCode(#1'.el.select("input[type=checkbox]:nth('+(i+1).ToString+')").elements[0].checked='+Selected[i].ToString.ToLower+';');

Compiler seems to be complaining about .ToString and .ToLower  and the error is: "E2018 Record, object or class type required"

 

Does anyone know what changes I would need to make to the above so it builds?


  • 0

#6 arilotta

arilotta

    Advanced Member

  • uniGUI Subscriber
  • PipPipPipPip
  • 105 posts
  • LocationTrieste, Italy

Posted 31 January 2018 - 07:41 AM

It should be sufficient to substitute "Selected[i].ToString.ToLower" with LowerCase(IntToStr(Selected[i]))

 

Regards

Andrea


  • 0

#7 mos

mos

    Advanced Member

  • uniGUI Subscriber
  • PipPipPipPip
  • 167 posts

Posted 31 January 2018 - 09:11 AM

Hi Andrea,

 

  Since Selected[i] is a boolean should that actually be BoolToStr?


  • 0

#8 arilotta

arilotta

    Advanced Member

  • uniGUI Subscriber
  • PipPipPipPip
  • 105 posts
  • LocationTrieste, Italy

Posted 31 January 2018 - 09:29 AM

Yes, I think you're right.

Andrea


  • 0

#9 mos

mos

    Advanced Member

  • uniGUI Subscriber
  • PipPipPipPip
  • 167 posts

Posted 05 February 2018 - 06:40 AM

Hi Andrea,

 

  I noticed one issue. 

 

  If you use the object inspector to set the Items in design time I get AV in the RTL160.bpl.

 

  Do you have any issues setting the items in design time?


  • 0

#10 arilotta

arilotta

    Advanced Member

  • uniGUI Subscriber
  • PipPipPipPip
  • 105 posts
  • LocationTrieste, Italy

Posted 05 February 2018 - 08:37 AM

Hi mos, I corrected the issue you signaled, additionally in the newer version I'm attaching you'll find 2 new properties published:

- ReadOnly

- TrackOver

 

Bye

Andrea

 

 

Attached Files


  • 0

#11 mos

mos

    Advanced Member

  • uniGUI Subscriber
  • PipPipPipPip
  • 167 posts

Posted 06 February 2018 - 07:00 AM

Hi Andrea,

 

  Thanks for the update.  However I have noticed something odd.

 

  I have a simple project with just the main form,  a button and an empty TUniCheckListBox.

 

  On the button click I have the following code:

procedure TMainForm.UniButton1Click(Sender: TObject);
begin
  UniCheckListBox1.Items.Add('Item 1');
  UniCheckListBox1.Items.Add('Item 2');
  UniCheckListBox1.Items.Add('Item 3');

  UniCheckListBox1.Selected[1] := True;
end;

When I run the program and click the button I see the items in the listbox but the Selected[1] does not check the checkbox of the item.


  • 0

#12 arilotta

arilotta

    Advanced Member

  • uniGUI Subscriber
  • PipPipPipPip
  • 105 posts
  • LocationTrieste, Italy

Posted 06 February 2018 - 08:13 AM

It is something related to the way events are treated in Unigui.

Either:

 

- populate the CheckListBox at design time or at runtme in the FormCreate event; then handle just the initialization of Selected in the another event

 

- set EnableSynchronousOperations to TRUE in UniMainModule, then adjust your code in this way:

 

procedure TMainForm.testcl(Sender: TObject);
begin
  UniCheckListBox1.Items.Add('Item 1');
  UniCheckListBox1.Items.Add('Item 2');
  UniCheckListBox1.Items.Add('Item 3');
  UniSession.Synchronize;
  UniCheckListBox1.Selected[1]:=true;
end;

  • 0

#13 mos

mos

    Advanced Member

  • uniGUI Subscriber
  • PipPipPipPip
  • 167 posts

Posted 06 March 2018 - 05:30 AM

Hi Arilotta,

 

  Thank you for all your help so far.

 

   I've notice that highlight bar which is present in a normal UniGUI listbox is not present.

 

   Is it possible to show the highlight bar so the user knows which record is selected when you click on the item text?


  • 0

#14 arilotta

arilotta

    Advanced Member

  • uniGUI Subscriber
  • PipPipPipPip
  • 105 posts
  • LocationTrieste, Italy

Posted 06 March 2018 - 09:06 AM

It should be sufficient to replace "x-checklist-item" with "x-boundlist-item"  in procedure TUniCheckListBox.WebCreate,

in this line:

 

  '  list.tpl.html = ''<ul class="x-list-plain"><tpl for="."><li role="option" unselectable="on" class="x-boundlist-item" style="cursor: default;">'+


  • 0

#15 Ruslan

Ruslan

    Active Member

  • uniGUI Subscriber
  • PipPipPip
  • 58 posts

Posted 06 March 2018 - 09:16 PM

Can you attach screen to show how component looks?


  • 0

#16 arilotta

arilotta

    Advanced Member

  • uniGUI Subscriber
  • PipPipPipPip
  • 105 posts
  • LocationTrieste, Italy

Posted 07 March 2018 - 07:54 AM

See the attached screen shot.

Attached Files


  • 0

#17 mos

mos

    Advanced Member

  • uniGUI Subscriber
  • PipPipPipPip
  • 167 posts

Posted 07 March 2018 - 11:20 AM

Hi Arilotta,

 

  I made the change but noticed that you need to click the checkbox before the item is highlighted.

 

  What I would like is for the highlight bar to operate by just clicking on the row item rather than having to click the checkbox.

 

  In other words  the checkbox and highlight bar operate independently of each other.

 

  I played around with the change and I now understand what is happening.

 

  If you select an item by clicking the checkbox the item gets highlighted.

 

  Is it possible to remove the highlight bar when a checkbox is checked i.e. In other words I don't want the checked items to be highlighted?


  • 0

#18 MarBar77

MarBar77

    Active Member

  • uniGUI Subscriber
  • PipPipPip
  • 59 posts

Posted 11 March 2018 - 08:50 PM

Hi Andrea,

 

Thanks for sharing your component. I was interested with one more event, maybe someone else will need it.

 

Add new type:

 

TOnCheckChange = procedure(Sender: TObject; index: integer; newState: boolean) of object;

 

in private Add new Field:

 

FOnCheckChange: TOnCheckChange;

 

in public add new property:

 

property OnCheckChange: TOnCheckChange read FOnCheckChange write FOnCheckChange;

 

and in implementation of SetSelected method add new lines at the end of the method:

 

if Assigned(FOnCheckChange) then
  FOnCheckChange(self, index, Value);
 
now we have new event which is fired when someone check or unchecks any position on list giving us index and newstate of checkbox.
 
Regards,
Marcin
 

  • 0

#19 KdWpenza

KdWpenza

    Member

  • Members
  • PipPip
  • 23 posts
  • LocationRUSSIA

Posted 13 March 2018 - 05:36 AM

Hi Arilotta,

 

tell me please, this component is ported for the mobile version ???

 

Best regards,

  Dmitry.


  • 0

#20 arilotta

arilotta

    Advanced Member

  • uniGUI Subscriber
  • PipPipPipPip
  • 105 posts
  • LocationTrieste, Italy

Posted 13 March 2018 - 07:36 AM

.@MarBar77 good job, I think it could be useful

 

@KdWpenza No, I haven't ported it to mobile...


  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users