Author Topic: Double Click in a List_Box  (Read 13405 times)

0 Members and 1 Guest are viewing this topic.

Lee Mac

  • Seagull
  • Posts: 12913
  • London, England
Double Click in a List_Box
« on: September 09, 2009, 08:29:50 AM »
In my current project I would like to be able to double click on an item in a DCL list_box and have another dialog open with this action, however the only way I have found to have a double click is the "allow_accept" attribute.

But this would follow the action of the tile with the "accept" key. Therefore I considered having an arbitrary tile with the "accept" key to perform the actions I wanted, but this would mean a superfluous tile on the dialog (unless such things can be hidden?)

I am a bit stumped as to how to approach this one - but I do believe it to be possible, as I have seen a similar thing in action in MP's axprops.fas application (a very nice piece of work indeed).

Any help is appreciated,

Thanks,

Lee

Andrea

  • Water Moccasin
  • Posts: 2372
Re: Double Click in a List_Box
« Reply #1 on: September 09, 2009, 09:26:12 AM »
Hi Lee..

Maybe this can Help..

Not very elegant...but it work.
Code: [Select]
(defun c:test (/ mylist dcl_id)
  (createleemacdialog)
  (setq dcl_id (load_dialog (strcat (getvar "SAVEFILEPATH") "test.dcl")))
  (if (not (new_dialog "test" dcl_id))
    (exit)
  )
  (setq mylist (list "Electrical" "Structural" "Plumbing" "Foundation"))
  (start_list "LB1" 3)
  (mapcar 'add_list mylist)
  (end_list)
  (action_tile
    "LB1"
    "(setq readlist (get_tile \"LB1\"))
    (if (eq (nth (atoi readlist) myList) firstitem)
    (progn
    (alert (nth (atoi readlist) myList))
    (setq firstitem nil)
    )   
    (setq firstitem (nth (atoi readlist) myList))
    )"
  )
  ;;ACTION 
  (action_tile "accept" "(done_dialog) (setq userclick T)")
  (action_tile "cancel" "(done_dialog) (setq userclick nil)")
  (start_dialog)
  (unload_dialog dcl_id)
  (princ)
)




(defun createleemacdialog (/ dialf)
  (setq dialf (open (strcat (getvar "SAVEFILEPATH") "test.dcl") "w"))
  (write-line
    "test  : dialog {
          label = \"test double click\" ;

: column {
: spacer {}

: boxed_column {
: spacer {}

label = \"ListBox :\";
 

: list_box {
        key = \"LB1\";       
        }


}

: spacer {}

        : text {     
        label = \"For LeeMac Only ! ;-)\";
        }
        : row {
  children_alignment = top ;
 
      }


}
: spacer {}

        ok_cancel ;

 }

"   dialf
  )
  (close dialf)
)

Keep smile...

Lee Mac

  • Seagull
  • Posts: 12913
  • London, England
Re: Double Click in a List_Box
« Reply #2 on: September 09, 2009, 09:34:28 AM »
Nice idea Andrea,

Thats a good substitute for the double click action - it doesn't emulate it exactly, as there can be an indefinite delay between the two clicks, but its pretty close  :-)

Thanks,

Lee

Andrea

  • Water Moccasin
  • Posts: 2372
Re: Double Click in a List_Box
« Reply #3 on: September 09, 2009, 10:07:47 AM »
maybe by adding this..

Code: [Select]
(defun c:test (/ mylist dcl_id)
  (createleemacdialog)
  (setq dcl_id (load_dialog (strcat (getvar "SAVEFILEPATH") "test.dcl")))
  (if (not (new_dialog "test" dcl_id))
    (exit)
  )
  (setq mylist (list "Electrical" "Structural" "Plumbing" "Foundation"))
  (start_list "LB1" 3)
  (mapcar 'add_list mylist)
  (end_list)
  (action_tile
    "LB1"
    "(setq readlist (get_tile \"LB1\"))
    (setq start# (getvar \"date\"))
    (if (and
        (eq (nth (atoi readlist) mylist) firstitem)
        (< (abs (read (rtos (- end# start#) 2 10))) 0.0000011667)
        )
       
      (progn (alert (nth (atoi readlist) mylist))
             (setq firstitem nil)
      )
      (progn
      (setq end# (getvar \"date\"))
      (setq firstitem (nth (atoi readlist) mylist))
      )
    )"
  )
  ;;ACTION 
  (action_tile "accept" "(done_dialog) (setq userclick T)")
  (action_tile "cancel" "(done_dialog) (setq userclick nil)")
  (start_dialog)
  (unload_dialog dcl_id)
  (princ)
)

(rtos (getvar  "date") 2 8)



(defun createleemacdialog (/ dialf)
  (setq dialf (open (strcat (getvar "SAVEFILEPATH") "test.dcl") "w"))
  (write-line
    "test  : dialog {
          label = \"test double click\" ;

: column {
: spacer {}

: boxed_column {
: spacer {}

label = \"ListBox :\";
 

: list_box {
        key = \"LB1\";       
        }


}

: spacer {}

        : text {     
        label = \"For LeeMac Only ! ;-)\";
        }
        : row {
  children_alignment = top ;
 
      }


}
: spacer {}

        ok_cancel ;

 }

"   dialf
  )
  (close dialf)
)


Keep smile...

Lee Mac

  • Seagull
  • Posts: 12913
  • London, England
Re: Double Click in a List_Box
« Reply #4 on: September 09, 2009, 10:14:41 AM »
Haven't tried your most recent post yet - but I had a dabble with this:

Code: [Select]
(defun c:test (/ mylist dcl_id ptr acptr)
  (createleemacdialog)
  (setq dcl_id (load_dialog (strcat (getvar "SAVEFILEPATH") "test.dcl")))
  (if (not (new_dialog "test" dcl_id))
    (exit)
  )
  (setq mylist (list "Electrical" "Structural" "Plumbing" "Foundation"))
  (start_list "LB1" 3)
  (mapcar 'add_list mylist)
  (end_list)

  (action_tile "accept" "(or (and acPtr
                                  (not (alert (nth (atoi acPtr) mylist)))
                                  (not (setq acPtr nil)))
                             (done_dialog))")
  (action_tile "LB1"    "(or (and (eq ptr $value)
                                  (not (setq acPtr ptr ptr nil)))
                             (setq ptr $value))")
  (action_tile "cancel" "(done_dialog)")

  (start_dialog)
  (unload_dialog dcl_id)
  (princ)
)




(defun createleemacdialog (/ dialf)
  (setq dialf (open (strcat (getvar "SAVEFILEPATH") "test.dcl") "w"))
  (write-line
    "test  : dialog {
          label = \"test double click\" ;

: column {
: spacer {}

: boxed_column {
: spacer {}

label = \"ListBox :\";
 

: list_box {
        key = \"LB1\";
        allow_accept = true;
        }


}

: spacer {}

        : text {     
        label = \"For LeeMac + Andrea Only ! ;-)\";
        }
        : row {
  children_alignment = top ;
 
      }


}
: spacer {}

        ok_cancel ;

 }

"   dialf
  )
  (close dialf)
)


Lee Mac

  • Seagull
  • Posts: 12913
  • London, England
Re: Double Click in a List_Box
« Reply #5 on: September 09, 2009, 10:16:29 AM »
Very nice Andrea! - I like your thinking... when I said there was an indefinite about of time between clicks, you took this literally and put a cap on that time... nice thinking  8-)

Andrea

  • Water Moccasin
  • Posts: 2372
Re: Double Click in a List_Box
« Reply #6 on: September 09, 2009, 10:22:24 AM »
Very nice Andrea! - I like your thinking... when I said there was an indefinite about of time between clicks, you took this literally and put a cap on that time... nice thinking  8-)

Thanks !   :angel:
that way you will be able to set double-click delay. :ugly:
Keep smile...

Lee Mac

  • Seagull
  • Posts: 12913
  • London, England
Re: Double Click in a List_Box
« Reply #7 on: September 09, 2009, 10:31:49 AM »
A slightly tider action statement:

Code: [Select]
(action_tile "LB1"
    "(setq start# (getvar \"date\"))
     (if (and (eq ptr $value)
              (< (abs (read (rtos (- end# start#) 2 10))) 0.0000011667))
             
      (progn
      (alert (nth (atoi ptr) mylist))
             (setq ptr nil))
             
      (setq end# (getvar \"date\") ptr $value))"
  )

Andrea

  • Water Moccasin
  • Posts: 2372
Re: Double Click in a List_Box
« Reply #8 on: September 09, 2009, 10:41:39 AM »
A slightly tider action statement:

Code: [Select]
(action_tile "LB1"
    "(setq start# (getvar \"date\"))
     (if (and (eq ptr $value)
              (< (abs (read (rtos (- end# start#) 2 10))) 0.0000011667))
             
      (progn
      (alert (nth (atoi ptr) mylist))
             (setq ptr nil))
             
      (setq end# (getvar \"date\") ptr $value))"
  )

not sure to understand...

why (eq ptr $value) ?
$value and ptr always = nil ?
Keep smile...

Lee Mac

  • Seagull
  • Posts: 12913
  • London, England
Re: Double Click in a List_Box
« Reply #9 on: September 09, 2009, 10:42:35 AM »
$value is the value of the tile when the action_tile is triggered  :-)

Andrea

  • Water Moccasin
  • Posts: 2372
Re: Double Click in a List_Box
« Reply #10 on: September 09, 2009, 10:48:21 AM »
$value is the value of the tile when the action_tile is triggered  :-)

oh ! I see... :?

nice...!!  thanks !
Keep smile...

GDF

  • Water Moccasin
  • Posts: 2081
Re: Double Click in a List_Box
« Reply #11 on: September 09, 2009, 12:16:22 PM »
Code: [Select]
;;;double clicking on image tile
(defun ARCH:SET_X (a) (setq x a))
(defun ARCH:READ_X  (a)
  (if (= x a)
    (done_dialog)))

(action_tile
    "S1"
    "(ARCH:READ_X 1)(RESETNO-OFF)(ARCH:PLAY-SYM \"S1\" \"North\" \"Arrow\")(ARCH:SET_X 1)")


This is what I do for double clicking on button in a dialog box.

In the SYMS dialog box image below, a single click changes the image and a double click does the action.
The S1 image is in the upper left (north arrow) button.
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64

jbuzbee

  • Swamp Rat
  • Posts: 851
Re: Double Click in a List_Box
« Reply #12 on: September 09, 2009, 01:00:21 PM »
. . . psst: OpenDCL.com

all the cool kids are doing it . . .  8-)
James Buzbee
Windows 8

Andrea

  • Water Moccasin
  • Posts: 2372
Re: Double Click in a List_Box
« Reply #13 on: September 09, 2009, 01:03:30 PM »
. . . psst: OpenDCL.com

all the cool kids are doing it . . .  8-)

I prefer ObjectDCL.com   :pissed:
Keep smile...

Lee Mac

  • Seagull
  • Posts: 12913
  • London, England
Re: Double Click in a List_Box
« Reply #14 on: September 09, 2009, 01:13:19 PM »
. . . psst: OpenDCL.com

all the cool kids are doing it . . .  8-)

I prefer ObjectDCL.com   :pissed:

I haven't tried either tbh...

Andrea, is ObjectDCL part of your company?

JBuz >  I have had a look at OpenDCL.com - may look into getting into it... not sure how easy it is to get to grips with though...   :|