本文整理汇总了C#中Gtk.TextView.GrabFocus方法的典型用法代码示例。如果您正苦于以下问题:C# TextView.GrabFocus方法的具体用法?C# TextView.GrabFocus怎么用?C# TextView.GrabFocus使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Gtk.TextView
的用法示例。
在下文中一共展示了TextView.GrabFocus方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DynamicCodePage
/// <summary>
/// Initializes a new instance of the <see cref="DynamicCodeTests.DynamicCodePage"/> class.
/// </summary>
public DynamicCodePage(Project project, CodeWindow codeWindow)
{
Trace.Log(TraceEventType.Information, "project=\"{0}\", codeWindow=\"{1}\"", project.ToString(), codeWindow.ToString());
Project = project;
CodeWindow = codeWindow;
DynamicCompiler = new Compiler(project);
lockOutput.AcquireWriterLock(0);
int mark = 0;
ScrolledWindow w = new ScrolledWindow();
tvInput = new TextView();
w.AddWithViewport(tvInput);
Pack2(w, false, true);
w = new ScrolledWindow();
tvOutput = new TextView();
tvOutput.Editable = false;
w.AddWithViewport(tvOutput);
Pack1(w, true, true);
Position = 234;
PositionSet = true;
tvInput.GrabFocus();
List<string> codeHistory = project.CodeHistory;
tvInput.KeyReleaseEvent += delegate(object o, KeyReleaseEventArgs args)
{
if (args.Event.State.HasFlag(Gdk.ModifierType.ControlMask))
{
if (args.Event.Key.Equals(Gdk.Key.space))
ShowCompletions();
else if (args.Event.Key.Equals(Gdk.Key.Return))
ExecuteCode();
else if (codeHistory.Count > 0)
{
if (args.Event.Key.Equals(Gdk.Key.Up))
CodeHistoryUp();
else if (args.Event.Key.Equals(Gdk.Key.Down))
CodeHistoryDown();
}
}
else
{
codeHistoryIndex = -1;
}
tvInputPreviousText = tvInput.Buffer.Text;
};
lockOutput.ReleaseWriterLock();
ShowAll();
}
示例2: DemoApplicationWindow
public DemoApplicationWindow () : base ("Application Window")
{
SetDefaultSize (200, 200);
vbox = new VBox (false, 0);
Add (vbox);
AddActions ();
statusbar = new Statusbar ();
UpdateStatus ();
vbox.PackEnd (statusbar, false, false, 0);
ScrolledWindow sw = new ScrolledWindow ();
sw.SetPolicy (PolicyType.Automatic, PolicyType.Automatic);
sw.ShadowType = ShadowType.In;
vbox.PackEnd (sw, true, true, 0);
TextView textview = new TextView ();
textview.Buffer.MarkSet += new MarkSetHandler (MarkSet);
sw.Add (textview);
textview.GrabFocus ();
ShowAll ();
}
示例3: SwitchTitleView
/// <summary>
/// See SwitchContentView.
/// This is an awkward solution and should be refactored.
/// The only other way I can think if is creating two different
/// EventHandlers, and they call with different parameters which
/// Label and TextView to switch (Content or Title).
/// </summary>
/// <param name='edit'>
/// If true, paint a TextView that can be edited.
/// If false, paint a Label that displays memo.
/// </param>
public void SwitchTitleView(bool edit)
{
if (edit) {
// Removing the label
_titleLabelListener.Destroy();
// Setting up the textview
_titleTextView = new TextView ();
_titleTextView.FocusInEvent += new FocusInEventHandler(MemoTextViewGotFocus);
_titleTextView.FocusOutEvent += new FocusOutEventHandler(MemoTitleTextViewLostFocus);
TextBuffer contentBuffer = _titleTextView.Buffer;
contentBuffer.Text = this._item.GetTitle();
_titleTextView.SetSizeRequest (200, 140);
_titleTextView.Justification = Justification.Fill;
_titleTextView.WrapMode = WrapMode.Word;
_titleAlignment.Add (_titleTextView);
_titleTextView.GrabFocus();
} else {
// Saving information from textview and removing it
this._item.SetTitle(_titleTextView.Buffer.Text);
Console.WriteLine ("Setting memo title to " + _titleTextView.Buffer.Text);
_titleTextView.Destroy();
// Creating label
_titleLabel = new Label();
_titleLabel.Text = this._item.GetTitle ();
_titleLabel.SetSizeRequest (200, 80);
_titleLabel.SetAlignment (0, 0);
_titleLabel.LineWrap = true;
_titleLabel.Justify = Justification.Fill;
// Label listener
_titleLabelListener = new EventBox ();
_titleLabelListener.ButtonPressEvent += new ButtonPressEventHandler (MemoTitlePressHandler);
_titleLabelListener.Add (_titleLabel);
_titleLabelListener.SetSizeRequest(200, 80);
_titleAlignment.Add (_titleLabelListener);
}
this._container.ShowAll();
}