mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2025-12-26 15:57:56 +01:00
* Improved a better clipped screen. Fixes some bugs with ScrollView, Menu. Added some virtual methods. * Added some more key features, like shift. Cleaning and updating some stuffs .Added more features to TextField. * Closes the menu even in a button pressed in another view than menu. * Added a OnKeyPress action. Now all the keys events are properly mapped to the keys modifiers. Fixed a issue which keys like (ã, á, â) aren't correctly written. * Fixed an issue with the shift flag for keys ControlA_Z. * Ensures quiting the terminal if no other option is provided by pressing Ctrl-Q * Ensures the exception is thrown before ordered.Reverse. * Changed Button4 To Button3 for CursesDriver compatibility. * Added support for word selection through keyboard and the mouse. With triple click all text is selected. * Changed AllowNewLine to AllowWrap. * Fix topological sort in view class (#413) * AllowWrap removed and keys issues fixed. * Removing ordered.Reverse (); Something went wrong. * Fixes FrameView title. * Reverted some MapKeyModifiers that prevented the display of some characters. * Avoiding open the menu-bar every time we typing (€@£§). Alt key now only highlight the menu-bar without open it. * Fixes hot-key issue preventing menu closing after opened. * Curses now supports hot-keys and simulates AltMask with Alt+Space. Also supports shift and ctrl combinations to use with text selection. * Maintains the menu highlighted while focused. * Removed the IsOutBounds method. This feature is for a future presentation. Co-authored-by: En3Tho <37334640+En3Tho@users.noreply.github.com>
132 lines
3.3 KiB
C#
132 lines
3.3 KiB
C#
using System;
|
|
using Terminal.Gui;
|
|
using Attribute = Terminal.Gui.Attribute;
|
|
|
|
namespace Designer {
|
|
class Surface : Window {
|
|
public Surface () : base ("Designer")
|
|
{
|
|
}
|
|
}
|
|
|
|
class MainClass {
|
|
static void Close ()
|
|
{
|
|
MessageBox.ErrorQuery (50, 7, "Error", "There is nothing to close", "Ok");
|
|
}
|
|
|
|
static void Copy ()
|
|
{
|
|
TextField textField = menu.LastFocused as TextField;
|
|
if (textField != null && textField.SelectedLength != 0) {
|
|
textField.Copy ();
|
|
}
|
|
}
|
|
|
|
static void Cut ()
|
|
{
|
|
TextField textField = menu.LastFocused as TextField;
|
|
if (textField != null && textField.SelectedLength != 0) {
|
|
textField.Cut ();
|
|
}
|
|
}
|
|
|
|
static void Paste ()
|
|
{
|
|
TextField textField = menu.LastFocused as TextField;
|
|
if (textField != null) {
|
|
textField.Paste ();
|
|
}
|
|
}
|
|
|
|
public static MenuBar menu;
|
|
|
|
public static void Main (string [] args)
|
|
{
|
|
Application.Init ();
|
|
|
|
menu = new MenuBar (new MenuBarItem [] {
|
|
new MenuBarItem ("_File", new MenuItem [] {
|
|
new MenuItem ("_Close", "", () => Close ()),
|
|
new MenuItem ("_Quit", "", () => { Application.RequestStop (); })
|
|
}),
|
|
new MenuBarItem ("_Edit", new MenuItem [] {
|
|
new MenuItem ("_Copy", "", Copy),
|
|
new MenuItem ("C_ut", "", Cut),
|
|
new MenuItem ("_Paste", "", Paste)
|
|
}),
|
|
});
|
|
|
|
var login = new Label ("Login: ") { X = 3, Y = 6 };
|
|
var password = new Label ("Password: ") {
|
|
X = Pos.Left (login),
|
|
Y = Pos.Bottom (login) + 1
|
|
};
|
|
var test = new Label ("Test: ") {
|
|
X = Pos.Left (login),
|
|
Y = Pos.Bottom (password) + 1
|
|
};
|
|
|
|
var surface = new Surface () {
|
|
X = 0,
|
|
Y = 1,
|
|
Width = Dim.Percent (50),
|
|
Height = Dim.Percent (50)
|
|
};
|
|
|
|
var loginText = new TextField("") {
|
|
X = Pos.Right(password),
|
|
Y = Pos.Top(login),
|
|
Width = Dim.Percent(90),
|
|
ColorScheme = new ColorScheme() {
|
|
Focus = Attribute.Make(Color.BrightYellow, Color.DarkGray),
|
|
Normal = Attribute.Make(Color.Green, Color.BrightYellow),
|
|
HotFocus = Attribute.Make(Color.BrightBlue, Color.Brown),
|
|
HotNormal = Attribute.Make(Color.Red, Color.BrightRed),
|
|
},
|
|
};
|
|
loginText.MouseEnter += LoginText_MouseEnter;
|
|
loginText.MouseLeave += LoginText_MouseLeave;
|
|
loginText.Enter += LoginText_Enter;
|
|
loginText.Leave += LoginText_Leave;
|
|
|
|
var passText = new TextField ("") {
|
|
Secret = true,
|
|
X = Pos.Left (loginText),
|
|
Y = Pos.Top (password),
|
|
Width = Dim.Width (loginText)
|
|
};
|
|
|
|
var testText = new TextField ("") {
|
|
X = Pos.Left (loginText),
|
|
Y = Pos.Top (test),
|
|
Width = Dim.Width (loginText)
|
|
};
|
|
|
|
surface.Add (login, password, test, loginText, passText, testText);
|
|
Application.Top.Add (menu, surface);
|
|
Application.Run ();
|
|
}
|
|
|
|
private static void LoginText_Leave (object sender, EventArgs e)
|
|
{
|
|
((TextField)sender).Text = $"Leaving from: {sender}";
|
|
}
|
|
|
|
private static void LoginText_Enter (object sender, EventArgs e)
|
|
{
|
|
((TextField)sender).Text = $"Entering in: {sender}";
|
|
}
|
|
|
|
private static void LoginText_MouseLeave (object sender, MouseEvent e)
|
|
{
|
|
((TextField)sender).Text = $"Mouse leave at X: {e.X}; Y: {e.Y} HasFocus: {e.View.HasFocus}";
|
|
}
|
|
|
|
private static void LoginText_MouseEnter (object sender, MouseEvent e)
|
|
{
|
|
((TextField)sender).Text = $"Mouse enter at X: {e.X}; Y: {e.Y} HasFocus: {e.View.HasFocus}";
|
|
}
|
|
}
|
|
}
|