Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Is there a way to create a checkbox list?

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
Razi
Expert Cheater
Reputation: 1

Joined: 17 Jan 2018
Posts: 202

PostPosted: Tue Mar 26, 2019 2:18 am    Post subject: Is there a way to create a checkbox list? Reply with quote

Is there a way to create a checkbox list on the form? Need to create 50 checkboxes on the one object with scroll down by mouse wheel.


2v85G-.jpg
 Description:
 Filesize:  3.57 KB
 Viewed:  5285 Time(s)

2v85G-.jpg


Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 457

Joined: 09 May 2003
Posts: 25262
Location: The netherlands

PostPosted: Tue Mar 26, 2019 3:40 am    Post subject: Reply with quote

No, there is no way to get the selected items right now

but you can show it using
Code:

clb=createComponentClass('TCheckListBox',formname)
clb.Parent=formname

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1667

PostPosted: Tue Mar 26, 2019 6:03 am    Post subject: This post has 1 review(s) Reply with quote

Dark Byte wrote:
No, there is no way to get the selected items right now

but you can show it using
Code:

clb=createComponentClass('TCheckListBox',formname)
clb.Parent=formname


I am using CE 6.8.3, when trying the code above its give error message "Access Violation' and also Scrollbox does not work on form designer.

Btw, I try this method as a wish on topic.


Code:
function createScrollBox(Parent)
local scrbox = createComponentClass('TScrollBox', Parent)
 scrbox.Parent = Parent
 return scrbox
end

f = createForm()
f.Width = 150
f.Height = 600

a = createScrollBox(f)
a.Top = 10
a.Left = 10
a.Width = 130
a.Height = 580
a.Color = '0xFFFFFF'
a.VertScrollBar.Increment = 200
a.VertScrollBar.Page = 700
a.VertScrollBar.Smooth = true
a.VertScrollBar.Range = 700

local ctop=10
local i
for i=1,50 do
 local cbxname='cbx'..i
 local cbx=createCheckBox(a)
  _G[cbxname]=cbx
  cbx.Left = 10
  cbx.Top = ctop
  ctop=ctop+20
  cbx.caption = "+/- "..i
end



Check Box On Scroll Bar Group.JPG
 Description:
Check Boxes Child on Scrollbox
 Filesize:  31.45 KB
 Viewed:  5256 Time(s)

Check Box On Scroll Bar Group.JPG



_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL
Back to top
View user's profile Send private message
Razi
Expert Cheater
Reputation: 1

Joined: 17 Jan 2018
Posts: 202

PostPosted: Tue Mar 26, 2019 6:53 am    Post subject: Reply with quote

What does this "a.VertScrollBar.Page = 700" parameter do? When I change it, nothing changes. CE 6.7 version
Back to top
View user's profile Send private message
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1667

PostPosted: Tue Mar 26, 2019 8:24 am    Post subject: Reply with quote

Razi wrote:
What does this "a.VertScrollBar.Page = 700" parameter do? When I change it, nothing changes. CE 6.7 version


I am also not sure for what purpose VertScrollBar.Page in CE because not able to test it in the form designer, anyhow on it set default value = 8. Increment value = 1.

According to Windows Web API Page Control, method :

Scrollbar.pages = The number of pages to scroll. It may be a positive or negative integer.

In Windows Web API, example work in a browser :

Code:
// scroll down the document by 1 page
window.scrollByPages(1);

// scroll up the document by 1 page
window.scrollByPages(-1);

_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL
Back to top
View user's profile Send private message
Razi
Expert Cheater
Reputation: 1

Joined: 17 Jan 2018
Posts: 202

PostPosted: Tue Mar 26, 2019 8:58 am    Post subject: Reply with quote

Can I use your method "function createScrollBox(Parent) ..." in CE 6.5 version? Because in CE 6.7 this method works, in CE 6.5 it gives an error: Undefined lua error. attempt to call a nil value (global 'createComponentClass')
Back to top
View user's profile Send private message
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1667

PostPosted: Tue Mar 26, 2019 11:01 am    Post subject: Reply with quote

Quote:
Can I use your method "function createScrollBox(Parent) ..." in CE 6.5 version?


If I do not miss it, I think no. TScrollBox added since CE 6.6 and 'createComponentClass' also not registered yet on CE 6.5.
CE 6.5 have createClass(object) but cannot use to make scroll box component, since TScrollBox unregistered on CE Main.pas or there are no TScrollBox.pas defined

_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL
Back to top
View user's profile Send private message
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1667

PostPosted: Wed Mar 27, 2019 5:16 am    Post subject: Reply with quote

Tested on CE 6.8.3 to create CheckListBox with ScrollBar

Code:
function createCListBox(Parent)
local clb = createComponentClass('TCheckListBox', Parent)
 clb.Parent = Parent
 return clb
end

f = createForm()
a = createCListBox(f)
a.top = 10
a.left = 10
a.height = 60
a.width = 200
a.Color = '0x00DFF7FF'
a. ScrollWidth = 10
a.Items.Clear()
a.Items.Add('First line');
a.Items.Add('Line with random number ')
a.Items.Add('Third line')
a.Items.Add('Even a random number ')



Capture.JPG
 Description:
CE 6.8.3 Check List Box
 Filesize:  17.45 KB
 Viewed:  5188 Time(s)

Capture.JPG



_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL
Back to top
View user's profile Send private message
Razi
Expert Cheater
Reputation: 1

Joined: 17 Jan 2018
Posts: 202

PostPosted: Thu Mar 28, 2019 6:06 am    Post subject: Reply with quote

@Corroder: Thank you
Back to top
View user's profile Send private message
paul44
Expert Cheater
Reputation: 2

Joined: 20 Jul 2017
Posts: 152

PostPosted: Fri Oct 15, 2021 11:28 am    Post subject: Height defines "size" of scrollbox...? Reply with quote

I'm currently using above function to manage structures (delete selectively), but ran into a snag: the "size/contents" of the scrollbox seems to be defined/limited by its 'Height' property ?i! (see here: [ https://imgur.com/a/ye7RwfS ])

Any solution (besides increasing the height; which becomes impractical as i'd like to limit the form_size that holds it ~ right image) ?

I've also looked at this solution: [ https://www.cheatengine.org/forum/viewtopic.php?p=5736908&sid=54b40917275ac4ebb78fc9665a8a3141 ].
The problem i encountered here is that - even with 'MultiSelect = true' - the 'Selected[]' array will only return 'true' for the last_selected ?! (iow i get total list of items, but only one - last selected - shows 'true')
(also: in this list, it seems difficult to select the visible "bottom" item in that list; it will always select the next one...?)

ps: i also came across some Listbox examples. I would be able to work something out with those examples, but prefer the 'checkbox' interface more...
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 457

Joined: 09 May 2003
Posts: 25262
Location: The netherlands

PostPosted: Fri Oct 15, 2021 5:59 pm    Post subject: Reply with quote

use anchors

Code:

a.Achors="[akTop, akLeft, akBottom]"
a.AnchorSideBottom.Control=deleteButton
a.AnchorSideBottom.Side=asrTop


and anchor the delete button to the bottom of the form

Code:

deleteButton.Anchors="[akLeft,akBottom]"
deleteButton.AnchorSideBottom.Control=f
deleteButton.AnchkrSideBottom.Side=asrBottom


(i'm on my phone so there may be some typos there)

it's a lot easier to instead of lua use the formdesigner to create the form and use the anchor configure tool there

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
paul44
Expert Cheater
Reputation: 2

Joined: 20 Jul 2017
Posts: 152

PostPosted: Sat Oct 16, 2021 12:27 am    Post subject: panel perhaps...? Reply with quote

thx for the suggestions; i'll give that a try later this weekend. I'm also going to try with a panel, and "dump" the listbox in there...?

ps: never mind about syntax issues; i've seen already plenty of posts referring to 'anchors'; so no worries. and I can't even recall when last using the FormDesigner (let alone having the final form integrated as such), but will do some research on that one as well...

- Update 1 -
I could not immediately work it out with the 'anchors'... I'll try that later via the FormDesigner.
However: worked out a solution using a Panel. Bizar detail: previously i needed to change 'a.height' to get a complete list; now i need to update 'VertScrollBar.Range' (~panel effect perhaps)?! Anyways this seems to work now: [ https://imgur.com/a/EEJYDp0 ] (note that this list/gap is influenced by your screen resolution, since i'm trying to calc "pixel_space" for a font_size (at least, that's what i make of it)
(ps: did some research back then on how to calculate such "relationship", but that is no easy feat so dropped it Embarassed )
- EDIT - actually: disabling/not_using 'a.VertScrollBar.Range' seems to solve this issue...

I'll be uploading the code here: [ https://fearlessrevolution.com/viewtopic.php?p=213846#p213846 ] (in case you're interested)

Still to check out: FormDesigner approach...

can/could span some days before updating my final results !


Last edited by paul44 on Sun Oct 17, 2021 4:36 am; edited 1 time in total
Back to top
View user's profile Send private message
paul44
Expert Cheater
Reputation: 2

Joined: 20 Jul 2017
Posts: 152

PostPosted: Sun Oct 17, 2021 3:54 am    Post subject: Using the FormDesigner... Reply with quote

Took me some reading, but now got this far: [ https://imgur.com/a/xsNMRDH ]

I understood from another topic (here: [ https://www.cheatengine.org/forum/viewtopic.php?p=5736908&sid=54b40917275ac4ebb78fc9665a8a3141 ]) that 'Selected' is an array "linear"-related to the Items_array. Iow Selected[5] corresponds/refers to Items[5]. And so I'm assuming that - when 'MultiSelect' is enabled - those respective flags would be set accordingly?!
For now, it only seems to return the last_selected (in the example: selecting 25, then 23 will return 23 as 'true' only...)

Q: what am i missing/doing_wrong here? (see EDIT2)


-EDIT- a solution: manage your own IsSelect_array; and use 'OnClickCheck'
(see here: [ https://imgur.com/a/jeNkx60 ])
-EDIT2 -: I misinterpreted the 'Selected' flag; it does work in combination with [Ctrl]. However: when selecting checkboxes individually, then only the last_selected is 'Checked' !

some observations:
a. it takes some initial investment, but FormDesigner should definitely be on your interest_list (especially when doing stuff like this)
b. the checklist nicely adapts appropriately: adding/removing items will align the list as expected ! (no screen_res issues here)
c. no overlap/anchor/etc to bother either; comes right out of the box as shown here
d. CE allows you to save the form as LFM form (basically you'll get all property_settings listed in there, in case you'd like to use that in some lua code/andwhatnot)
e. came across another article (about 'Starbound' CT table): [ https://www.cheatengine.org/forum/viewtopic.php?p=5575778&sid=c2a004a3ce7b8607fa9ff1f756568f22#5575778 ] Really helpful on how to integrate/manipulate such form
f. Rydian also made a tuturial 'Custom Trainer' here: [ https://www.cheatengine.org/forum/viewtopic.php?p=5587205&sid=144d3646f6b548dd6e2bf124eceede1a ] (unfortunately all images got "killed"...)
g. oh yeah: the form is saved in your CT table (see [Table] menu)

UPDATE: i'm considering my topic_request as closed.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites