dilan Posted May 8, 2020 Posted May 8, 2020 (edited) Hello! How can I track when working in a while when a user presses a button "+" on the keyboard? I will be glad to advice. Thank. Edited May 8, 2020 by dilan Quote
Jonathan Handojo Posted May 8, 2020 Posted May 8, 2020 Can you perhaps be a bit more specific? Â Post a sample code. Quote
dlanorh Posted May 8, 2020 Posted May 8, 2020 33 minutes ago, dilan said: Hello! How can I track when working in a loop when a user presses a button "+" on the keyboard? I will be glad to advice. Thank.  Not sure how you will implement it, but I think you'll have to use grread  (defun rh:get_keypress (keys / key asc c flg) (while (null flg) (setq key (grread)) (cond ( (= 13 (cadr key)) (setq flg T)) ( (= (car key) 2) (setq asc (cadr key) c (chr asc) flg (member asc (vl-string->list keys)))) ) ) c )  pass in keys, which is a string, so if you want to capture the + key (rh:get_keypress "+")  they only problem is that it will wait for a key press. 1 Quote
dilan Posted May 8, 2020 Author Posted May 8, 2020 10 minutes ago, Jonathan Handojo said: Can you perhaps be a bit more specific?  Post a sample code. Yes of course Here is the piece of code: (while (= 5 (car (setq pnt (grread nil 13 0)))) ; ЦИКЛ ************************ (redraw) (setq p (cadr pnt)) (setq xof 15 yof 10 scl (/ (getvar 'viewsize) (cadr (getvar 'screensize))) str (mapcar 'rtos p) txtp (list (+ (car p) (* xof scl)) (+ (cadr p) (* yof scl)) (+ (caddr p) 1)) ); end of setq (setq txt "\\PExample!" ) (setq etxt (list (cons 0 "MTEXT") (cons 100 "AcDbEntity") (cons 62 1) (cons 100 "AcDbMText") (cons 10 txtp) (cons 40 (* 15 scl)) (cons 1 txt) (cons 7 (getvar 'textstyle)) ); end of list ) (if prevtxt (entdel prevtxt)) (setq prevtxt (entmakex etxt)) ); end of while (redraw) (if prevtxt (entdel prevtxt))  Quote
dilan Posted May 8, 2020 Author Posted May 8, 2020 27 minutes ago, dlanorh said:  Not sure how you will implement it, but I think you'll have to use grread  (defun rh:get_keypress (keys / key asc c flg) (while (null flg) (setq key (grread)) (cond ( (= 13 (cadr key)) (setq flg T)) ( (= (car key) 2) (setq asc (cadr key) c (chr asc) flg (member asc (vl-string->list keys)))) ) ) c )  pass in keys, which is a string, so if you want to capture the + key (rh:get_keypress "+")  they only problem is that it will wait for a key press. Thank! Quote
dilan Posted May 8, 2020 Author Posted May 8, 2020 And when I click the "+" button in the drawing the text "Example!" is created Quote
dlanorh Posted May 8, 2020 Posted May 8, 2020 46 minutes ago, dilan said: And when I click the "+" button in the drawing the text "Example!" is created  If you want to include it in your grread code, (setq var (grread...) returns (x y) to var on an event. If x = 2 it is a keyboard input and y is the ascii value of the key pressed (so for + key this would be (2 43) 1 Quote
dilan Posted May 8, 2020 Author Posted May 8, 2020 10 hours ago, dlanorh said: Â If you want to include it in your grread code, (setq var (grread...)Â returns (x y) to var on an event. If x = 2 it is a keyboard input and y is the ascii value of the key pressed (so for + key this would be (2 43) Thank you so much. Very helpful tip. I will try. Quote
BIGAL Posted May 8, 2020 Posted May 8, 2020 A quick question are you trying to limit keyboard input to known single keys, INITGET does that or other methods can be used. Quote
dilan Posted May 9, 2020 Author Posted May 9, 2020 8 hours ago, BIGAL said: A quick question are you trying to limit keyboard input to known single keys, INITGET does that or other methods can be used. a solution with a function grread helped me. I solved my problem. Thank you all for your help. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.