Add Copy() method to WebTextBox and WebTextArea, and fix margins of WebContainer using Row or Column arrangement.

[GB.WEB.FORM]
* BUG: Fix margins of WebContainer using Row or Column arrangement.
* NEW: The '~dump' request now displays the environment variables too.
* NEW: WebTextBox.Copy() is a new method that copies the control text to the clipboard. Works only with https.
* NEW: WebTextArea.Clear() is a new method that clears the control text.
* NEW: WebTextArea.Copy() is a new method that copies the control text to the clipboard. Works only with https.
This commit is contained in:
gambas 2018-12-19 10:30:39 +01:00
parent d91451cf1e
commit da11a82b63
5 changed files with 62 additions and 14 deletions

View file

@ -184,6 +184,13 @@ Public Sub _RenderStyleSheet()
Endif
Endif
If $bSpacing Then
If $iArrangement = Arrange.Column Or If $iArrangement = Arrange.Row Then
Me._AddStyleSheet("padding-bottom: 0;")
Me._AddStyleSheet("padding-right: 0;")
Endif
Endif
Endif
If $bBorder Then Me._AddStyleSheet("border:solid #C0C0C0 1px;")

View file

@ -72,6 +72,7 @@ Static Public Sub Main()
Dim sFile As String
Dim sKey As String
Dim sErr As String
Dim sVar As String
'System.Log(Format(Timer, "#0.000") & ": start request: [" & Session.Id & "] " & URL.Decode(Application.Request))
@ -110,11 +111,16 @@ Static Public Sub Main()
Else If sPath = "~dump" Then
Response.ContentType = "text/plain;charset=utf-8"
Response.Begin
For Each sVar In Env
Print sVar; " = "; Env[sVar]
Next
If Session.Id Then
Response.ContentType = "text/plain;charset=utf-8"
Response.Begin
Print
For Each sKey In Session.Keys
Print sKey; " : "; JSON.Encode(Session[sKey])
Next
@ -122,11 +128,11 @@ Static Public Sub Main()
Print
Print "size = "; Session.Size
Response.End
Return
Endif
Response.End
Return
Else If sPath = "~logout" Then
Session.Abandon

View file

@ -117,3 +117,18 @@ Private Sub PlaceHolder_Write(Value As String)
Me._SetProperty("PlaceHolder", Value)
End
Public Sub Clear()
Text_Write("")
End
Public Sub Copy()
WebForm._AddJavascript("gw.textarea.copy(" & JS(Me.Name) & ")")
End

View file

@ -63,6 +63,12 @@ Public Sub Clear()
End
Public Sub Copy()
WebForm._AddJavascript("gw.textbox.copy(" & JS(Me.Name) & ")")
End
Public Sub _Render()

View file

@ -1403,15 +1403,29 @@ gw = {
copy: function(id)
{
var ret = false;
var elt = $(id);
var save = gw.saveFocus();
gw.setFocus(id);
gw.setSelection(elt, [0, elt.value.length]);
try { document.execCommand('copy'); } catch(e) { gw.log('Unable to copy: ' + e); ret = true; }
gw.restoreFocus(save);
return ret;
navigator.clipboard.writeText($(id + ':entry').value)
.then(() => {
// Success!
})
.catch(err => {
console.log('Unable to copy to the clipboard: ', err);
});
}
},
textarea:
{
copy: function(id)
{
navigator.clipboard.writeText($(id).value)
.then(() => {
// Success!
})
.catch(err => {
console.log('Unable to copy to the clipboard: ', err);
});
}
}
}