fixed placeholder text on password inputs
This commit is contained in:
parent
e8ac296f35
commit
a62ffc41ad
|
@ -149,12 +149,40 @@ jobs:
|
||||||
|
|
||||||
- name: Create GitHub Release
|
- name: Create GitHub Release
|
||||||
uses: actions/create-release@v1
|
uses: actions/create-release@v1
|
||||||
|
id: create_release
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
with:
|
with:
|
||||||
tag_name: ${{ github.ref_name }}
|
tag_name: ${{ github.ref_name }}
|
||||||
release_name: Release ${{ github.ref_name }}
|
release_name: Release ${{ github.ref_name }}
|
||||||
draft: false
|
draft: false
|
||||||
prerelease: false
|
prerelease: false
|
||||||
files: |
|
- name: Upload AppImage
|
||||||
./release-assets/*.AppImage
|
uses: actions/upload-release-asset@v1
|
||||||
./release-assets/*.exe
|
env:
|
||||||
./release-assets/*.dmg
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
with:
|
||||||
|
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||||
|
asset_path: ./release-assets/*.AppImage
|
||||||
|
asset_name: PlayerLink.AppImage
|
||||||
|
asset_content_type: application/octet-stream
|
||||||
|
|
||||||
|
- name: Upload Windows Executable
|
||||||
|
uses: actions/upload-release-asset@v1
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
with:
|
||||||
|
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||||
|
asset_path: path_to_your_windows_executable
|
||||||
|
asset_name: ./release-assets/*.exe
|
||||||
|
asset_content_type: application/octet-stream
|
||||||
|
|
||||||
|
- name: Upload macOS DMG
|
||||||
|
uses: actions/upload-release-asset@v1
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
with:
|
||||||
|
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||||
|
asset_path: ./release-assets/*.dmg
|
||||||
|
asset_name: PlayerLink.dmg
|
||||||
|
asset_content_type: application/octet-stream
|
||||||
|
|
34
src/main.cpp
34
src/main.cpp
|
@ -184,30 +184,37 @@ public:
|
||||||
const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
|
const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
|
||||||
long style = 0, const wxValidator& validator = wxDefaultValidator,
|
long style = 0, const wxValidator& validator = wxDefaultValidator,
|
||||||
const wxString& name = "textCtrl")
|
const wxString& name = "textCtrl")
|
||||||
: wxTextCtrl(parent, id, value, pos, size, style, validator, name), placeholder(""), showPlaceholder(true) {
|
: wxTextCtrl(parent, id, value, pos, size, style, validator, name),
|
||||||
|
placeholder(""),
|
||||||
|
showPlaceholder(true),
|
||||||
|
isPassword((style & wxTE_PASSWORD) != 0) {
|
||||||
|
|
||||||
Bind(wxEVT_SET_FOCUS, &wxTextCtrlWithPlaceholder::OnFocus, this);
|
Bind(wxEVT_SET_FOCUS, &wxTextCtrlWithPlaceholder::OnFocus, this);
|
||||||
Bind(wxEVT_KILL_FOCUS, &wxTextCtrlWithPlaceholder::OnBlur, this);
|
Bind(wxEVT_KILL_FOCUS, &wxTextCtrlWithPlaceholder::OnBlur, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetPlaceholderText(const wxString& p) {
|
void SetPlaceholderText(const wxString& p) {
|
||||||
placeholder = p;
|
placeholder = p;
|
||||||
SetValue(placeholder);
|
if (GetValue().IsEmpty() || showPlaceholder)
|
||||||
Refresh();
|
UpdatePlaceholder();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void OnFocus(wxFocusEvent& event) {
|
void OnFocus(wxFocusEvent& event) {
|
||||||
if (GetValue() == placeholder)
|
if (showPlaceholder && GetValue() == placeholder) {
|
||||||
Clear();
|
Clear();
|
||||||
|
if (isPassword)
|
||||||
|
SetStyleToPassword();
|
||||||
|
}
|
||||||
|
|
||||||
showPlaceholder = false;
|
showPlaceholder = false;
|
||||||
event.Skip();
|
event.Skip();
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnBlur(wxFocusEvent& event) {
|
void OnBlur(wxFocusEvent& event) {
|
||||||
if (GetValue().IsEmpty() || GetValue() == "") {
|
if (GetValue().IsEmpty()) {
|
||||||
SetValue(placeholder);
|
|
||||||
showPlaceholder = true;
|
showPlaceholder = true;
|
||||||
|
UpdatePlaceholder();
|
||||||
}
|
}
|
||||||
event.Skip();
|
event.Skip();
|
||||||
}
|
}
|
||||||
|
@ -215,6 +222,21 @@ protected:
|
||||||
private:
|
private:
|
||||||
wxString placeholder;
|
wxString placeholder;
|
||||||
bool showPlaceholder;
|
bool showPlaceholder;
|
||||||
|
bool isPassword;
|
||||||
|
|
||||||
|
void UpdatePlaceholder() {
|
||||||
|
if (isPassword)
|
||||||
|
SetStyleToNormal();
|
||||||
|
SetValue(placeholder);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetStyleToPassword() {
|
||||||
|
SetWindowStyle(GetWindowStyle() | wxTE_PASSWORD);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetStyleToNormal() {
|
||||||
|
SetWindowStyle(GetWindowStyle() & ~wxTE_PASSWORD);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class PlayerLinkFrame : public wxFrame {
|
class PlayerLinkFrame : public wxFrame {
|
||||||
|
|
Loading…
Reference in New Issue