当前位置: 首页>>代码示例>>C#>>正文


C# TextView.GrabFocus方法代码示例

本文整理汇总了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();
        }
开发者ID:jbowwww,项目名称:JGL,代码行数:62,代码来源:DynamicCodePage.cs

示例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 ();
		}
开发者ID:ystk,项目名称:debian-gtk-sharp2,代码行数:26,代码来源:DemoApplicationWindow.cs

示例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();
 }
开发者ID:tomgud,项目名称:Memorize,代码行数:48,代码来源:MemoItemDisplay.cs


注:本文中的Gtk.TextView.GrabFocus方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。