Posts: 726
Threads: 99
Joined: Mar 2018
04-20-2019, 01:21 AM
(This post was last modified: 04-20-2019, 01:26 AM by win .)
How to display the items in the list selection dialog directly to the combo box on the right, as shown in the picture below
The best way is that when I click on an item in the left combo box, the right combo box can directly display the items in it.
This is a comprehensive example, I hope someone can finish it, thanks in advance
Macro
Macro3
out
str s.getsel
QMITEM q; int i
ARRAY ( str ) atn
rep
, i= qmitem ( - i 1 | 16 & q 1 )
, if ( i= 0 ) break
, if q.itype= 4
,, atn[]= q.name
_s= atn
str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 334 188 "Add AutoText"
;14 Button 0x54032000 0x0 144 12 48 14 "Edit"
;3 ComboBox 0x54230641 0x0 11 8 120 173 ""
;4 ComboBox 0x54230641 0x0 204 8 120 172 ""
;END DIALOG
;DIALOG EDITOR: "" 0x2040801 "*" "" "" ""
str controls = "3 4"
str cb3 cb4
cb3= _s
if ( ! ShowDialog ( dd & sub.DlgProc & controls)) ret
#sub DlgProc
function # hDlg message wParam lParam
sel message
, case WM_INITDIALOG
, CB_SelectString ( id ( 3 hDlg) "test" )
, case WM_DESTROY
, case WM_COMMAND goto messages2
ret
;messages2
sel wParam
, case IDOK
, case IDCANCEL
, case 10 ;;Add
, DT_Ok hDlg
, case 14 ;;Edit
, _s.getwintext ( id ( 3 hDlg))
, str ssss items= sub.gotoitemedit ( _s)
, items.replacerx ( "\Q:sub.\E|\;" " " )
, _i= ListDialog ( items "Which item to Edit" "Select item" )
, if ( _i= 0 ) ret
, mac + _s
, int c= GetQmCodeEditor
, SendMessage ( c SCI. SCI_GOTOLINE _i 0 )
, ssss.getl ( items _i- 1 )
, ssss.trim
, ;int ii=findrx(ssss "\d" 0 1)
, int ii= findrx ( ssss "Sub." 0 1 )
, int cp= SendMessage ( c SCI. SCI_GETCURRENTPOS 0 0 )
, cp+ ii
, SendMessage ( c SCI. SCI_GOTOPOS cp 0 )
ret 1
#sub gotoitemedit
function ~ ~ name
str pattern= "(?:.*\:sub\..*)"
_s.getmacro ( name 0 )
str ss d
int i
ARRAY ( str ) a
findrx ( _s pattern 0 4 a)
for i 0 a.len
, d.formata ( "%s[]" a[0 i])
ret d.trim
The following code sometimes does not match the data, for example:
Autotext
test
Trigger
$t
/b/i/c/m
ata : sub.Sub2 ;;china
tes : sub.Sub1 ;;commnet
hel : "hello world" ;;hello world
#sub Sub1 m ;;tes commnet
_s=
F
;english name
;english name2
PasteAutoInputDialog ( _s)
#sub Sub2 m ;;ata china
_s=
F
;china
PasteAutoInputDialog ( _s)
#sub gotoitemedit
function~ ~name
str pattern="(?:.*\:sub\..*)"
_s.getmacro(name 0)
str ss d
int i
ARRAY(str) a
findrx(_s pattern 0 4 a)
for i 0 a.len
,d.formata("%s[]" a[0 i])
ret d.trim
Attached Files
Image(s)
Posts: 1,337
Threads: 61
Joined: Jul 2006
04-20-2019, 01:49 AM
(This post was last modified: 04-20-2019, 01:50 AM by Kevin .)
single left click left combo to select item. Double left click right combo to open and goto code. Edit button is not needed
Function
Dialog_Edit_Autotext
out
str s.getsel
QMITEM q; int i
ARRAY ( str ) atn
rep
, i= qmitem ( - i 1 | 16 & q 1 )
, if ( i= 0 ) break
, if q.itype= 4
,, atn[]= q.name
_s= atn
str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 334 188 "Edit Existing AutoText"
;3 ComboBox 0x54230641 0x0 11 8 120 173 ""
;4 ComboBox 0x54230641 0x0 145 8 174 172 ""
;END DIALOG
;DIALOG EDITOR: "" 0x2040802 "*" "" "" ""
str controls = "3 4"
str cb3 cb4
cb3= _s
if ( ! ShowDialog ( dd & sub.DlgProc & controls)) ret
#sub DlgProc
function # hDlg message wParam lParam
sel message
, case WM_INITDIALOG
, CB_SelectString ( id ( 3 hDlg) "test" )
, case WM_DESTROY
, case WM_COMMAND goto messages2
ret
;messages2
int hcb2= id ( 4 hDlg) ;;combo box
sel wParam
, case IDOK
, case IDCANCEL
, case 10 ;;Add
, DT_Ok hDlg
, case CBN_SELENDOK << 16 | 3
, str cb1si
, _i= CB_SelectedItem ( lParam cb1si)
, str cb2ii itemscb2= sub.gotoitemedit ( cb1si)
, SendMessage ( hcb2 CB_RESETCONTENT 0 0 )
, itemscb2.findreplace ( ":sub." " " )
, itemscb2.findreplace ( ";;" " " )
, foreach cb2ii itemscb2
,, CB_Add ( hcb2 cb2ii)
, case CBN_DBLCLK << 16 | 4
, str cb2t
, _i= CB_SelectedItem ( lParam cb2t)
, _s.getwintext ( id ( 3 hDlg))
, mac + _s
, int c= GetQmCodeEditor
, SendMessage ( c SCI. SCI_GOTOLINE _i+ 1 0 )
, int ii= findrx ( cb2t "Sub." 0 1 )
, int cp= SendMessage ( c SCI. SCI_GETCURRENTPOS 0 0 )
, cp+ ii
, SendMessage ( c SCI. SCI_GOTOPOS cp 0 )
ret 1
#sub gotoitemedit
function ~ ~ name
str pattern= "(?:.*\:sub\..*)"
_s.getmacro ( name 0 )
str ss d
int i
ARRAY ( str ) a
findrx ( _s pattern 0 4 a)
for i 0 a.len
, d.formata ( "%s[]" a[0 i])
ret d.trim
Posts: 1,337
Threads: 61
Joined: Jul 2006
04-20-2019, 02:11 AM
(This post was last modified: 04-20-2019, 02:17 AM by Kevin .)
yes would need to change the pattern findrx searches for and would also need to adjust find replace code as well
"In addition, I need to change the items in the list to the following, is it possible?"
possible yes but i forsee a problem when autotext is only single line.
Posts: 726
Threads: 99
Joined: Mar 2018
04-20-2019, 02:22 AM
(This post was last modified: 04-20-2019, 02:40 AM by win .
Edit Reason: Problem
)
I added a filter search function to the edit box in the combo box (This is very useful when there are a lot of items in the list ), see the GIF below.
But The only problem now is that
the filtered results cannot be displayed in real time in the list of combo boxes.
I searched a lot in the forum, but I didn't find the answer. Is this impossible?
Macro Code+filter
[size=large]out
str s.getsel
QMITEM q; int i
ARRAY ( str ) atn
rep
, i= qmitem ( - i 1 | 16 & q 1 )
, if ( i= 0 ) break
, if q.itype= 4
,, atn[]= q.name
_s= atn
ARRAY ( str ) aList= atn
IQmDropdown ddl
int inERS
str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 334 188 "Edit Existing AutoText"
;3 ComboBox 0x54230641 0x0 11 8 120 173 ""
;4 ComboBox 0x54230641 0x0 145 8 174 172 ""
;END DIALOG
;DIALOG EDITOR: "" 0x2040802 "*" "" "" ""
str controls = "3 4"
str cb3 cb4
cb3= _s
if ( ! ShowDialog ( dd & sub.DlgProc & controls)) ret
#sub DlgProc
function # hDlg message wParam lParam
sel message
, case WM_INITDIALOG
, CB_SelectString ( id ( 3 hDlg) "test" )
, case WM_DESTROY
, case WM_COMMAND goto messages2
ret
;messages2
int hcb2= id ( 4 hDlg) ;;combo box
sel wParam
, case IDOK
, case IDCANCEL
, case 10 ;;Add
, DT_Ok hDlg
, case CBN_SELENDOK << 16 | 3
, str cb1si
, _i= CB_SelectedItem ( lParam cb1si)
, str cb2ii itemscb2= sub.gotoitemedit ( cb1si)
, SendMessage ( hcb2 CB_RESETCONTENT 0 0 )
, itemscb2.findreplace ( ":sub." " " )
, itemscb2.findreplace ( ";;" " " )
, foreach cb2ii itemscb2
,, CB_Add ( hcb2 cb2ii)
, case CBN_DBLCLK << 16 | 4
, str cb2t
, _i= CB_SelectedItem ( lParam cb2t)
, _s.getwintext ( id ( 3 hDlg))
, mac + _s
, int c= GetQmCodeEditor
, SendMessage ( c SCI. SCI_GOTOLINE _i+ 1 0 )
, int ii= findrx ( cb2t "Sub." 0 1 )
, int cp= SendMessage ( c SCI. SCI_GETCURRENTPOS 0 0 )
, cp+ ii
, SendMessage ( c SCI. SCI_GOTOPOS cp 0 )
,
, case CBN_EDITCHANGE << 16 | 3 sub.OnTextChanged lParam
,
ret 1
#sub gotoitemedit
function ~ ~ name
str pattern= "(?:.*\:sub\..*)"
_s.getmacro ( name 0 )
str ss d
int i
ARRAY ( str ) a
findrx ( _s pattern 0 4 a)
for i 0 a.len
, d.formata ( "%s[]" a[0 i])
ret d.trim
#sub OnTextChanged v
function hEdit
if ( inERS) ret
if ( ddl) ddl.Close ; ddl= 0
str s.getwintext ( hEdit)
if ( ! s.len) ret
ICsv x._create
x.AddRow1 ( 0 "" )
int i
for i 0 aList.len
, if ( find ( aList[i] s 0 1 ) < 0 ) continue
, x.AddRow1 ( - 1 aList[i])
if ( ! x.RowCount ) ret
if ( ShowDropdownList ( x i 0 1 hEdit 0 0 0 ddl) & QMDDRET_SELOK = 0 ) ret
s= x.Cell ( i+ 1 0 )
inERS= 1
EditReplaceSel hEdit 0 s 1
inERS= 0 [/size]
possible yes but i forsee a problem when autotext is only single line.
When a single line of text, the front number shows 0
There is a problem now
When I press the esc key, the dialog will close.
I want to implement:
A. when I press the esc key,
empty the contents of the edit box in the upper left corner, and the cursor is positioned in the edit box.
B. When I press the esc key twice,
close the window.
How to achieve?
Attached Files
Image(s)
Posts: 726
Threads: 99
Joined: Mar 2018
04-20-2019, 10:23 AM
(This post was last modified: 04-20-2019, 10:24 AM by win .)
Current code, there are two questions: (Below is an animated GIF demo and related code )
1. After the highlight code is displayed, the cursor position is at the end, and F2 cannot be used directly.
2. If there is a single-line AutoText, the positioning is not accurate.
_____________________________________________________________________
I have a feature request:
When I press the mouse right click on the AutoText, I can execute it instead of opening it.
For example, when I right click on sub.sub3, the Notepad program will open.
Autotext test
Trigger $t
[size=large]/b/i/c/m
ata : sub.Sub2 ;;china
tes : sub.Sub1 ;;commnet
te : "hello" ;;heloo
te : sub.Sub3 ;;run notepad
#sub Sub1 m ;;tes commnet
_s=
F
;english name
;english name2
PasteAutoInputDialog ( _s)
#sub Sub2 m ;;ata china
_s=
F
;china
PasteAutoInputDialog ( _s)
#sub Sub3 m ;;te run notepad
run "notepad" [/size]
Macro Code+filter
[size=large]out
str s.getsel
QMITEM q; int i
ARRAY ( str ) atn
rep
, i= qmitem ( - i 1 | 16 & q 1 )
, if ( i= 0 ) break
, if q.itype= 4
,, atn[]= q.name
_s= atn
ARRAY ( str ) aList= atn
IQmDropdown ddl
int inERS
str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 334 188 "Edit Existing AutoText"
;3 ComboBox 0x54230641 0x0 11 8 120 173 ""
;4 ComboBox 0x54230641 0x0 145 8 174 172 ""
;END DIALOG
;DIALOG EDITOR: "" 0x2040802 "*" "" "" ""
str controls = "3 4"
str cb3 cb4
cb3= _s
if ( ! ShowDialog ( dd & sub.DlgProc & controls)) ret
#sub DlgProc
function # hDlg message wParam lParam
sel message
, case WM_INITDIALOG
, CB_SelectString ( id ( 3 hDlg) "test" )
,
, case WM_DESTROY
,
, case WM_COMMAND goto messages2
ret
;messages2
int hcb2= id ( 4 hDlg) ;;combo box
sel wParam
, case IDOK
,
, case IDCANCEL
,
, case CBN_SELENDOK << 16 | 3
, str cb1si
, _i= CB_SelectedItem ( lParam cb1si)
, str cb2ii itemscb2= sub.gotoitemedit ( cb1si)
, SendMessage ( hcb2 CB_RESETCONTENT 0 0 )
, itemscb2.findreplace ( ":sub." " " )
, itemscb2.findreplace ( ";;" " " )
, foreach cb2ii itemscb2
,, CB_Add ( hcb2 cb2ii)
,
, case CBN_DBLCLK << 16 | 4
, str cb2t
, _i= CB_SelectedItem ( lParam cb2t)
, _s.getwintext ( id ( 3 hDlg))
, mac + _s
, int c= GetQmCodeEditor
, SendMessage ( c SCI. SCI_GOTOLINE _i+ 1 0 )
, int ii= findrx ( cb2t "Sub." 0 1 )
, int cp= SendMessage ( c SCI. SCI_GETCURRENTPOS 0 0 )
, cp+ ii
, SendMessage ( c SCI. SCI_GOTOPOS cp 0 )
,
, SendMessage ( c SCI. SCI_SETSELBACK 0 0x00FF00 )
, ' SE
,
, case CBN_EDITCHANGE << 16 | 3 sub.OnTextChanged lParam
,
ret 1
#sub gotoitemedit
function ~ ~ name
str pattern= "(?:.*\:sub\..*)"
_s.getmacro ( name 0 )
str ss d
int i
ARRAY ( str ) a
findrx ( _s pattern 0 4 a)
for i 0 a.len
, d.formata ( "%s[]" a[0 i])
ret d.trim
#sub OnTextChanged v
function hEdit
if ( inERS) ret
if ( ddl) ddl.Close ; ddl= 0
str s.getwintext ( hEdit)
if ( ! s.len) ret
ICsv x._create
x.AddRow1 ( 0 "" )
int i
for i 0 aList.len
, if ( find ( aList[i] s 0 1 ) < 0 ) continue
, x.AddRow1 ( - 1 aList[i])
if ( ! x.RowCount ) ret
if ( ShowDropdownList ( x i 0 1 hEdit 0 0 0 ddl) & QMDDRET_SELOK = 0 ) ret
s= x.Cell ( i+ 1 0 )
inERS= 1
EditReplaceSel hEdit 0 s 1
inERS= 0 [/size]
Attached Files
Image(s)