Hello,
currently itemList only returns an array of the --->selected items<----

if a list has this selected it returns fine

item 0
item 1
item 2
item 3

the problem is i Cant move an item UP or DOWN, the list doesnt update unless i mouse click the item again,
i dont know how to explain anymore, or even understand what iam saying to explain this...

this thing only gives you values throw a signal and the user has to mouse click on it

itemLlist1.multi_selected.connect(self.itemLlist1_selected); 

var itemListNum: int = 0;
var itemselected: bool = true;

func itemLlist1_selected(index, selected):
	#print(  str(index) + str("  ") + str(selected)   );
	itemListNum = index;
	itemselected = selected;
	PlugTileDrawNode.layerPOS = index;

this way when i move an item UP or DOWN it doesnt update the correct position, like get_selected_items ( ) does...
it only gives you the currect position if you use that signal.

Is there a way to get all items on the list ?
so i can make it work togheter with the get_selected_items ( )

    jonSS Is there a way to get all items on the list ?

    itemList.get_children() ??

      kuligs2 it gives an empty array

      var a = itemList.get_children()
      print( "itemList: " + str( a ) )
      
      returns this -> []

      i guess the items arent its childern

      • xyz replied to this.

        jonSS Item are identified by indices. So a collection of all existing items is simply an implicit collection of all indices from 0 to N-1. Since you always know how many items there are via item_count property, you always implicitly know the items.

          xyz thanks, it seems the problem is another thing

          I need to push the value in an array up or down
          currently there is only push_back and push_front and this add a value in front or back...
          I cant do it by copying the values and change place

          this is the array: layers.Lnum

          var layers = {
          	'Lnum': [ {} ]
          }

          this is how its being set up:

          func _draw():
          	
          	if ( Engine.is_editor_hint() ):		
          	
          	for p in range(0, layerMax ):
          		for i in layers.Lnum[p]:
          			if ( layers.Lnum[p].has(i) ):
          				draw_texture( layers.Lnum[p][i], i );

          I wanted this layers.Lnum[] to change positions up or down withOut loosing the contents that are on it

          [EDIT]

          chatGPT says array in godot4 has the 'move' method...

          In Godot 4, you can change the positions of values in an array using the move method or by manually swapping elements. Below are examples of both methods.
          Using the move Method

          The move method is built into the Array class in Godot and allows you to move an element from one position to another within the array.

            jonSS Use Array::remove_at() and Array::insert()
            Check the Array class reference for details

              xyz it wont work
              iam going to have to do this, in multiple diferent button functions

              				var a1 = layers.Lnum[n+1];
              				var a2 = layers.Lnum[n];
              				layers.Lnum[n] = a1;
              				layers.Lnum[n+1] = a2;

              and... i have an itemList Select Mode to multiple
              iam using an itemList has a menu, to change an array on another script

              • xyz replied to this.

                jonSS array in godot4 has the 'move' method...

                Array does not have a move() method.

                ItemList has a move() method.

                  jonSS You're not making much sense here. Are you dealing with an array or an item list? Seems you are confused by mixing up those two things.
                  Let's start over. Fully describe what exactly you're trying to accomplish. What's your goal, not your attempted solutions.

                  Oh, and stay away from ChatGPT.

                    DaveTheCoder
                    I have the ItemList on an EditorInspectorPlugin in the right Dock Inspector
                    And the Array on a costum node the EditorPlugin handles

                    How iam supossed to do this ?
                    iam going to have to start over, and then i will find more unsolvable problems, like adding a dictionary to an itemList

                    • xyz replied to this.

                      xyz stay away from ChatGPT.

                      That's nonsense. Just treat ChatGPT as a very knowledgeable person who sometimes provides correct information and sometimes provides incorrect information. I.e., don't trust the information without confirming it.

                      • xyz replied to this.

                        jonSS ItemList is just a gui widget, not a data storage. Items cannot hold references to any data other than their displayed strings and an item associated metadata. If the list is meant to represent some other separate data structure, you'll need to manage that connection manually. So if you want to change the order of items in an ItemList as well as in some data structure (array or dictionary) that the list represents, you'll need to do it on both things.

                        xyz

                        the editor plugIN
                        loads an instance and the EditorInspectorPlugin and creates a costum node

                        @tool
                        extends EditorPlugin
                        
                        const menuScene = preload("res://menu/menu.tscn");
                        const tileDrawNode = preload("res://test3/tileDrawNode.gd");
                        const tileDrawIcon = preload("res://test3/icon.png");
                        
                        #---------//---inspector---//---------
                        var tlDrawInspector = preload("res://addons/tiledrawtest2/tileDrawInspector.gd");
                        
                        func _enter_tree():
                        	add_custom_type("TileDraw", "Node2D", tileDrawNode, tileDrawIcon );
                        	dockedScene = menuScene.instantiate();
                        	add_control_to_container(CONTAINER_CANVAS_EDITOR_SIDE_RIGHT, dockedScene );
                        	dockedScene.custom_minimum_size = Vector2(10,0);
                        	
                        	tlDrawInspector  = tlDrawInspector.new();
                        	tlDrawInspector.PlugInDockedScene = dockedScene;
                        	add_inspector_plugin(tlDrawInspector);
                        
                        var TileDrawNode;
                        
                        func _handles(object: Object) -> bool:
                        	#return object is tileDrawNode
                        	if ( object is tileDrawNode ):
                        		TileDrawNode = object;
                        		return true
                        	return false

                        the costum node 'tileDrawNode' draws all of this stuff in engine editor screen

                        @tool
                        extends Node2D
                        class_name tileDrawX1;
                        
                        var layers = {
                        	'Lnum': [ {} ]
                        }
                        
                        		for i in range(0, drawText.get_image().get_size().x,32 ):
                        			for j in range(0,  drawText.get_image().get_size().y, 32):
                        				
                        				mouseGroup.Fnum.append(  { "cords": Vector2(i, j), "img": ImageTexture.create_from_image(drawText.get_image().get_region( Rect2( i, j, 32, 32) ) ) } );
                        
                        
                        func _draw():
                        
                        	for p in range(0, layerMax ):
                        		for i in layers.Lnum[p]:
                        			if ( layers.Lnum[p].has(i) ):
                        				draw_texture( layers.Lnum[p][i], i );

                        and the EditorInspectorPlugin adds a menu to the inspector with the itemList and other things

                        @tool
                        extends EditorInspectorPlugin
                        
                        var itemLlist1;
                        
                        func _can_handle(object):
                        	if object is tileDrawX1:
                        		PlugTileDrawNode = object;
                        		return true
                        	return false
                        
                        
                        
                        func _parse_end(object):
                        	itemLlist1 = ItemList.new();
                        	itemLlist1.set_custom_minimum_size(Vector2(100, 90));
                        	itemLlist1.set( "theme_override_styles/focus",StyleBoxEmpty.new() );
                        	itemLlist1.select_mode = 1;
                        
                        	for n in 3:
                        		itemLlist1.add_item("     layer " + str(n) );
                        	
                        	itemLlist1.select(0, true);
                        	
                        	var listSize = itemLlist1.get_item_count();
                        	for n in range( listSize-1 ):
                        		if ( PlugTileDrawNode.layers.Lnum.size() <  listSize  ):
                        			PlugTileDrawNode.layers.Lnum.append( {} ); 
                        
                        
                        func btn_UpLayer_pressed(): # move layers UP
                        	var listSize = itemLlist1.get_item_count();
                        	PlugTileDrawNode.layerMax = listSize;
                        	#PlugTileDrawNode.add_layers();
                        	
                        	var itemListSize = itemLlist1.get_item_count();
                        	var itemListSelectedItems = itemLlist1.get_selected_items();
                        	
                        	for n in itemListSize:
                        		if ( itemListSelectedItems.has(n) && n >= 1 ):
                        			if ( itemListSelectedItems[0] != 0 ):
                        				#itemLlist1.move_item(n, n - 1);
                        				itemLlist1.move_item(itemListSelectedItems[0], n - 1);
                        				
                        				var a1 = PlugTileDrawNode.layers.Lnum[n-1];
                        				var a2 = PlugTileDrawNode.layers.Lnum[n];
                        				PlugTileDrawNode.layers.Lnum[n] = a1;
                        				PlugTileDrawNode.layers.Lnum[n-1] = a2;

                        This things cant communicate with one an other... I have to pass them on to the other using a var.
                        If i had an itemList on both sides the result would be the same

                        EditorInspectorPlugin, doesnt have proccess() nor ready() the user selects the options there...
                        And putting this layers.Lnum in an itemList i dont know if its possible, i dont know whats going on inside an itemList ?
                        I dont know if its an array or sometimes its already an array, drawing the list in the draw function could be possible i just dont know how.

                        • xyz replied to this.

                          DaveTheCoder That's nonsense. Just treat ChatGPT as a very knowledgeable person who sometimes provides correct information and sometimes provides incorrect information. I.e., don't trust the information without confirming it.

                          The irony. You just said yourself that ChatGPT is redundant; Let's not check a reliable source immediately. Let's waste time with a chatbot and then check if what it blurted out is valid at that reliable source. Yeah, totally makes sense.
                          ChatGPT shouldn't be treated as a "very knowledgeable person". It should be treated like what it is - a statistical linguistic token sequencer.

                            jonSS So the ItemList represents your layers array?

                            xyz Yeah, totally makes sense.

                            If you're going to keep posting nonsense, at least keep it out of this kind of discussion so it doesn't confuse users who need help.

                              DaveTheCoder If you're going to keep posting nonsense

                              You're not the "nonsense" police around here, Dave. If you proclaim something a nonsense, you'll have to provide some arguments that support that claim. An user cited faulty information gotten from ChatGPT. I said stay away from it. You said that's nonsense. How's what I said a nonsense in this context? The only nonsense here is what ChatGPT "said". And for some reason you proceeded to defend that source of faulty information. I'd really like to understand your motivations here.

                              So the ItemList represents your layers array?

                              yes
                              but itemList only returns an array with get_selected_items()

                              if i could get all the items on itemlist without having them selected maybe it could use it with the array on the other side
                              [edit] in the func process() also on the other side since EditorInspectorPlugin doesnt have process(), but it leads to a lot of confusion i have buttons to add and remove (layers)

                              p.s. chatGPT creates a loop

                              • xyz replied to this.

                                jonSS What do you mean by "get all the items on ItemList". What exact information you want to get for each item on the list?

                                  xyz
                                  I wanted to get an array from itemList
                                  and set the layers.Lnum array on the other side, to be equal to that array

                                  The problem is i have buttons to move items up or down, and to add or remove items
                                  I dont know how to make an array out of itemList without having to update it on all the buttons, and copy / paste all the layers multiple times, even if its possible it would be a waste to have 2 vars for each item... itemList would only function has a picture

                                  • xyz replied to this.