This commit is contained in:
zhuzichu 2023-11-08 10:30:22 +08:00
parent f0227c5686
commit cbebb51d62
2 changed files with 25 additions and 7 deletions

View File

@ -10,6 +10,7 @@ TextArea{
property color placeholderNormalColor: FluTheme.dark ? Qt.rgba(210/255,210/255,210/255,1) : Qt.rgba(96/255,96/255,96/255,1) property color placeholderNormalColor: FluTheme.dark ? Qt.rgba(210/255,210/255,210/255,1) : Qt.rgba(96/255,96/255,96/255,1)
property color placeholderFocusColor: FluTheme.dark ? Qt.rgba(152/255,152/255,152/255,1) : Qt.rgba(141/255,141/255,141/255,1) property color placeholderFocusColor: FluTheme.dark ? Qt.rgba(152/255,152/255,152/255,1) : Qt.rgba(141/255,141/255,141/255,1)
property color placeholderDisableColor: FluTheme.dark ? Qt.rgba(131/255,131/255,131/255,1) : Qt.rgba(160/255,160/255,160/255,1) property color placeholderDisableColor: FluTheme.dark ? Qt.rgba(131/255,131/255,131/255,1) : Qt.rgba(160/255,160/255,160/255,1)
property bool isCtrlEnterForNewline: false
id:control id:control
enabled: !disabled enabled: !disabled
color: { color: {
@ -20,7 +21,7 @@ TextArea{
} }
font:FluTextStyle.Body font:FluTextStyle.Body
wrapMode: Text.WrapAnywhere wrapMode: Text.WrapAnywhere
padding: 7 padding: 8
leftPadding: padding+4 leftPadding: padding+4
renderType: FluTheme.nativeText ? Text.NativeRendering : Text.QtRendering renderType: FluTheme.nativeText ? Text.NativeRendering : Text.QtRendering
selectedTextColor: color selectedTextColor: color
@ -44,11 +45,19 @@ TextArea{
QtObject{ QtObject{
id:d id:d
function handleCommit(event){ function handleCommit(event){
if(event.modifiers & Qt.ControlModifier){ if(isCtrlEnterForNewline){
if(event.modifiers & Qt.ControlModifier){
insert(control.cursorPosition, "\n")
return
}
control.commit(control.text)
}else{
if(event.modifiers & Qt.ControlModifier){
control.commit(control.text)
return
}
insert(control.cursorPosition, "\n") insert(control.cursorPosition, "\n")
return
} }
control.commit(control.text)
} }
} }
MouseArea{ MouseArea{

View File

@ -11,6 +11,7 @@ TextArea{
property color placeholderNormalColor: FluTheme.dark ? Qt.rgba(210/255,210/255,210/255,1) : Qt.rgba(96/255,96/255,96/255,1) property color placeholderNormalColor: FluTheme.dark ? Qt.rgba(210/255,210/255,210/255,1) : Qt.rgba(96/255,96/255,96/255,1)
property color placeholderFocusColor: FluTheme.dark ? Qt.rgba(152/255,152/255,152/255,1) : Qt.rgba(141/255,141/255,141/255,1) property color placeholderFocusColor: FluTheme.dark ? Qt.rgba(152/255,152/255,152/255,1) : Qt.rgba(141/255,141/255,141/255,1)
property color placeholderDisableColor: FluTheme.dark ? Qt.rgba(131/255,131/255,131/255,1) : Qt.rgba(160/255,160/255,160/255,1) property color placeholderDisableColor: FluTheme.dark ? Qt.rgba(131/255,131/255,131/255,1) : Qt.rgba(160/255,160/255,160/255,1)
property bool isCtrlEnterForNewline: false
id:control id:control
enabled: !disabled enabled: !disabled
color: { color: {
@ -45,11 +46,19 @@ TextArea{
QtObject{ QtObject{
id:d id:d
function handleCommit(event){ function handleCommit(event){
if(event.modifiers & Qt.ControlModifier){ if(isCtrlEnterForNewline){
if(event.modifiers & Qt.ControlModifier){
insert(control.cursorPosition, "\n")
return
}
control.commit(control.text)
}else{
if(event.modifiers & Qt.ControlModifier){
control.commit(control.text)
return
}
insert(control.cursorPosition, "\n") insert(control.cursorPosition, "\n")
return
} }
control.commit(control.text)
} }
} }
MouseArea{ MouseArea{