Listbox list positioning

Discussion in 'AutoCAD' started by Marcel Janmaat, Sep 16, 2003.

  1. I have a listbox in witch i generate a list wich is larger then the listbox
    itself. In this case scrollbars apear it the right side.
    By dubbelclicking on an item in the list a dialoge apears from witch i
    adjust it in a list wich wiil be regenerated in the listbox again. After
    this i set focus to selected item. Only what happens is that 'when i do this
    at a scrolled level in the list, the list will be displayed with it's focus
    at the last visible record. It's not realy a big problem, but not verry
    chic. I want the listbox not to flip all the records when i change an item
    in it.

    Is there someone who might have a solution for this?

    Regards MJ
     
    Marcel Janmaat, Sep 16, 2003
    #1
  2. Marcel Janmaat

    BillZ Guest

    To set the item in the list correctly:
    (start_list "my_tile_list") ;displays list
    (mapcar 'add_list mylist)
    (end_list)
    ;;;;;;;;;;;;;;;
    (set_tile "my_tile_list" (itoa (- (length mylist)(length (member item mylist))))) ;;;;;;//////
    ///////
    ///////
    Bill
     
    BillZ, Sep 16, 2003
    #2
  3. Thanx Bill,



     



    But i don't think this is the solution for me. I've tried it, and in this case the record also flip and focus is set to the next item at the bottem of the visible records.



     



    I want the records above the record i'm deleting to stay static (as they are) and the records under the record i'm deleting to shift up. This works fine when i'm deleting the exact last record in the list box. But if i'm halfway scrolled it always flips the records setting the focus to the last visible record.



     



    MJ





    "BillZ" <> schreef in bericht news:...

    To set the item in the list correctly:
    (start_list "my_tile_list") ;displays list
    (mapcar 'add_list mylist)
    (end_list)
    ;;;;;;;;;;;;;;;
    (set_tile "my_tile_list" (itoa (- (length mylist)(length (member item mylist))))) ;;;;;;//////
    ///////
    ///////
    Bill
     
    Marcel Janmaat, Sep 16, 2003
    #3
  4. Marcel Janmaat

    BillZ Guest

    I don't know exactly what you are doing but:
    Sound like you are getting the lists mixed up.
    If you are deleting an item from the list then you either have to change the list and redisplay it with the new index number, or use the change option of start_list and set the index number.
    Either way you need the index number and the list to correspond to each other.

    Bill
     
    BillZ, Sep 16, 2003
    #4
  5. Marcel Janmaat

    Jim Nelson Guest

    I think I understand what Marcel is looking for, because it is a problem with one of my own programs which exhibits the same behavior.  I have my code written so that if I pick one of the items in the list box, it removes the item and puts it in a different list box.  My original list is then updated, and the focus is moved to the next item down (the member of the list that showed below the item I had picked). In other words, if I pick the item that occupies index # 5, that item is removed from my list, and I rebuild the list with the list items above and below the one I picked.  I then reset the focus to index # 5.



     



    This works and looks fine on the upper list items (the one's that don't require the use of the scroll bar to see) until I scroll down the list and pick one of the lower index numbers.  Then, no matter which item I pick, when the focus returns to that index "slot", the dcl file will put it at the bottom of the list box if there are still enough members in the list to require the scroll bar.  Functionally it is no big deal, but it annoys those who use the program enough for them to ask for a cure (which I don't have)



     



    - Jim



     



    "BillZ" <> wrote in message news:...

    I don't know exactly what you are doing but:
    Sound like you are getting the lists mixed up.
    If you are deleting an item from the list then you either have to change the list and redisplay it with the new index number, or use the change option of start_list and set the index number.
    Either way you need the index number and the list to correspond to each other.

    Bill
     
    Jim Nelson, Sep 16, 2003
    #5
  6. Thanx for understanding Jim.



    I don't fully understand what the part in your first paragraph discribes, and why it matters to rebuild the list with the list items above and below the one I picked. I use just removing the item from the list instead. like (remove c '(a b cde))



     



    I was thinking there should be some kind of way to obtain witch records are visible. With that information i could perhaps reset the scroll position to those records in the newly generated listbox again and set focus to the next record.



     



    MJ



     



    "Jim Nelson" <> schreef in bericht news:...



    I think I understand what Marcel is looking for, because it is a problem with one of my own programs which exhibits the same behavior.  I have my code written so that if I pick one of the items in the list box, it removes the item and puts it in a different list box.  My original list is then updated, and the focus is moved to the next item down (the member of the list that showed below the item I had picked). In other words, if I pick the item that occupies index # 5, that item is removed from my list, and I rebuild the list with the list items above and below the one I picked.  I then reset the focus to index # 5.



     



    This works and looks fine on the upper list items (the one's that don't require the use of the scroll bar to see) until I scroll down the list and pick one of the lower index numbers.  Then, no matter which item I pick, when the focus returns to that index "slot", the dcl file will put it at the bottom of the list box if there are still enough members in the list to require the scroll bar.  Functionally it is no big deal, but it annoys those who use the program enough for them to ask for a cure (which I don't have)



     



    - Jim



     



    "BillZ" <> wrote in message news:...

    I don't know exactly what you are doing but:
    Sound like you are getting the lists mixed up.
    If you are deleting an item from the list then you either have to change the list and redisplay it with the new index number, or use the change option of start_list and set the index number.
    Either way you need the index number and the list to correspond to each other.

    Bill
     
    Marcel Janmaat, Sep 16, 2003
    #6
  7. Marcel Janmaat

    BillZ Guest

    I think I see the problem now.
    Try this and let me know if I'm in the ballpark.

    dcl_settings : default_dcl_settings
       { audit_level = 3 ;}
    testdcl: dialog {
        label = "Test";
            :list_box
               {
                label = "List box:" ;
                key = "ebox1" ;
                height = 5 ;
                fixed_height = true ;
                alignment = centered ;
            } //remarks
        ok_cancel;
    }
    ;;;;;;;
                                                      ;9/16/03 BILL ZONDLO
                                                      ;handler for test.dcl
                                                      ;
                                                      ;
    ;-------------------------------------------------;
     (defun set_lst (val)
        (setq itm (nth (atoi val) lst1)
                lst2 nil
          )
        (foreach n lst1
           (if (/= n itm)
               (setq lst2 (cons n lst2))
              )
            )
        (setq lst1 (reverse lst2))
        (start_list "ebox1")
        (mapcar 'add_list lst1)
        (end_list)
        (if (< (atoi val)(length lst1))
                    (set_tile "ebox1" val) ;highlighted item
                    (set_tile "ebox1" (itoa (1- (atoi val)))) ;highlighted item
         )
      )
    ;-------------------------------------------------;
     (defun c:test ( / dcl_id itm lst1 lst2)
       (setq dcl_id (load_dialog "testdcl.dcl"))
        (if (not (new_dialog "testdcl" dcl_id "" cl))
          (exit)
        )
       (setq lst1 (list "Item_1" "Item_2" "Item_3" "Item_4" "Item_5" "Item_6" "Item_7" "Item_8" "Item_9" "Item_10" "Item_11" "Item_12"))
       (start_list "ebox1")
       (mapcar 'add_list lst1)
       (end_list)
       (action_tile "ebox1" "(set_lst $value)")
       (action_tile "accept" "(done_dialog 1)")
       (action_tile "cancel" "(done_dialog 0)")
       (setq ans (start_dialog)
        )
       (unload_dialog dcl_id)
       (princ)
     )

    ;;;;;;;;;;;;;;Bill
     
    BillZ, Sep 16, 2003
    #7
  8. Marcel Janmaat

    Jim Nelson Guest

    Bill,



     



    Your code demonstrates it perfectly.  Run it and scroll down to, say, Item_6, so that it is visible in the middle of the box.  When you pick it, the focus is now at the bottom, instead of the middle.



     



    Thanks for writing the code to show it!



     



    - Jim



    "BillZ" <> wrote in message news:...

    I think I see the problem now.
    Try this and let me know if I'm in the ballpark.

    dcl_settings : default_dcl_settings
       { audit_level = 3 ;}
    testdcl: dialog {
        label = "Test";
            :list_box
               {
                label = "List box:" ;
                key = "ebox1" ;
                height = 5 ;
                fixed_height = true ;
                alignment = centered ;
            } //remarks
        ok_cancel;
    }
    ;;;;;;;
                                                      ;9/16/03 BILL ZONDLO
                                                      ;handler for test.dcl
                                                      ;
                                                      ;
    ;-------------------------------------------------;
     (defun set_lst (val)
        (setq itm (nth (atoi val) lst1)
                lst2 nil
          )
        (foreach n lst1
           (if (/= n itm)
               (setq lst2 (cons n lst2))
              )
            )
        (setq lst1 (reverse lst2))
        (start_list "ebox1")
        (mapcar 'add_list lst1)
        (end_list)
        (if (< (atoi val)(length lst1))
                    (set_tile "ebox1" val) ;highlighted item
                    (set_tile "ebox1" (itoa (1- (atoi val)))) ;highlighted item
         )
      )
    ;-------------------------------------------------;
     (defun c:test ( / dcl_id itm lst1 lst2)
       (setq dcl_id (load_dialog "testdcl.dcl"))
        (if (not (new_dialog "testdcl" dcl_id "" cl))
          (exit)
        )
       (setq lst1 (list "Item_1" "Item_2" "Item_3" "Item_4" "Item_5" "Item_6" "Item_7" "Item_8" "Item_9" "Item_10" "Item_11" "Item_12"))
       (start_list "ebox1")
       (mapcar 'add_list lst1)
       (end_list)
       (action_tile "ebox1" "(set_lst $value)")
       (action_tile "accept" "(done_dialog 1)")
       (action_tile "cancel" "(done_dialog 0)")
       (setq ans (start_dialog)
        )
       (unload_dialog dcl_id)
       (princ)
     )

    ;;;;;;;;;;;;;;Bill
     
    Jim Nelson, Sep 16, 2003
    #8
  9. Marcel Janmaat

    BillZ Guest

    No, It's not at the bottom. It's at the next item at the list, where I set it to be, Item_7, right?

    Bill
     
    BillZ, Sep 16, 2003
    #9
  10. Marcel Janmaat

    BillZ Guest

    Okay,
    I think I see what yo uare saying.
    I don't think there is anything you can do about it, as far as I know.

    Bill
     
    BillZ, Sep 16, 2003
    #10
  11. Okay Bill, thanks for the code. I haven't got time to check it out today or tomorrow. But i promise i get back to you on it.



     



     



    MJ



    "BillZ" <> schreef in bericht news:...

    I think I see the problem now.
    Try this and let me know if I'm in the ballpark.

    dcl_settings : default_dcl_settings
       { audit_level = 3 ;}
    testdcl: dialog {
        label = "Test";
            :list_box
               {
                label = "List box:" ;
                key = "ebox1" ;
                height = 5 ;
                fixed_height = true ;
                alignment = centered ;
            } //remarks
        ok_cancel;
    }
    ;;;;;;;
                                                      ;9/16/03 BILL ZONDLO
                                                      ;handler for test.dcl
                                                      ;
                                                      ;
    ;-------------------------------------------------;
     (defun set_lst (val)
        (setq itm (nth (atoi val) lst1)
                lst2 nil
          )
        (foreach n lst1
           (if (/= n itm)
               (setq lst2 (cons n lst2))
              )
            )
        (setq lst1 (reverse lst2))
        (start_list "ebox1")
        (mapcar 'add_list lst1)
        (end_list)
        (if (< (atoi val)(length lst1))
                    (set_tile "ebox1" val) ;highlighted item
                    (set_tile "ebox1" (itoa (1- (atoi val)))) ;highlighted item
         )
      )
    ;-------------------------------------------------;
     (defun c:test ( / dcl_id itm lst1 lst2)
       (setq dcl_id (load_dialog "testdcl.dcl"))
        (if (not (new_dialog "testdcl" dcl_id "" cl))
          (exit)
        )
       (setq lst1 (list "Item_1" "Item_2" "Item_3" "Item_4" "Item_5" "Item_6" "Item_7" "Item_8" "Item_9" "Item_10" "Item_11" "Item_12"))
       (start_list "ebox1")
       (mapcar 'add_list lst1)
       (end_list)
       (action_tile "ebox1" "(set_lst $value)")
       (action_tile "accept" "(done_dialog 1)")
       (action_tile "cancel" "(done_dialog 0)")
       (setq ans (start_dialog)
        )
       (unload_dialog dcl_id)
       (princ)
     )

    ;;;;;;;;;;;;;;Bill
     
    Marcel Janmaat, Sep 16, 2003
    #11
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.