Thread Rating:
  • 434 Vote(s) - 2.86 Average
  • 1
  • 2
  • 3
  • 4
  • 5
標準の右クリックメニューから一部機能を削除
05-09-2012, 11:47 AM,
#1
標準の右クリックメニューから一部機能を削除
標準の右クリックメニューから、
一部の機能だけを消すことって可能でしょうか?

メニュー自体の作り変えになるんじゃないかと思っているのですが・・

ご存知でしたら教えてください!

よろしくお願いいたします。
05-10-2012, 06:09 PM,
#2
RE: 標準の右クリックメニューから一部機能を削除
context-popupプロシージャを使えば結構簡単に制御できますよ。

こんな感じです。

Code:
{value
    let rect1:RectangleGraphic =
        {RectangleGraphic
            width=1in, height=0.5in,
            {context-popup
                menu-pane={MenuPane
                              {MenuAction
                                  label="Blue Fill",
                                  {on Action do
                                      set rect1.fill-color =
                                          "blue"}},
                              {MenuAction
                                  label="Red Fill",
                                  {on Action do
                                      set rect1.fill-color =
                                          "red"}}}}}
    rect1
}


05-10-2012, 06:29 PM,
#3
RE: 標準の右クリックメニューから一部機能を削除
たとえば以下のようにすると、
テキストフィールドの右クリックメニューから「削除」を取り除くことができます。

Code:
{curl 7.0 applet}
{curl-file-attributes character-encoding = "shift-jis"}

{define-class public MyTextFieldUI {inherits StandardTextFieldUI}
  {constructor {default ...}
    {construct-super {splice ...}}
  }
  {method private {make-menu-pane-for-text-field view:View}:MenuPane
    let fm:FocusManager = {non-null view.focus-manager}
    {return
        {MenuPane
            {MenuAction
                label = {host-localize "Cut"},
                bound-command = {fm.get-command "cut"} ||""
            },
            {MenuAction
                label = {host-localize "Copy"},
                bound-command = {fm.get-command "copy"} ||""
            },
            {MenuAction
                label = {Label
                            {host-localize "Paste"}
                        },
                bound-command = {fm.get-command "paste"} ||""
            }
        }
    }
  }
  {method open public {on-context-menu-event e:ContextMenuEvent}:void
    {if not e.consumed? then
        {if-non-null v = {self.get-view} then
            {if-non-null
                menu-pane = {self.make-menu-pane-for-text-field v}
             then
                {e.consume}
                {menu-pane.popup self, e.x, e.y}
            }
        }
    }
  }
}
{View
    {TextField ui-object = {MyTextFieldUI}},
    visibility = "normal",
    {on WindowClose do
        {exit}
    }
}
05-10-2012, 06:39 PM,
#4
RE: 標準の右クリックメニューから一部機能を削除
kimさん、ashimoさん

ありがとうございます!

ただ、これはどちらもメニューを作り変えてるということですよね?
作り変えずに、一機能だけ抜かすということはやはりできないのでしょうか?

よろしくお願いいたします。
03-04-2014, 04:04 PM,
#5
RE: 標準の右クリックメニューから一部機能を削除
自分のメニューのラベルから判断する方法がありそうです。
出来ればもっと厳密にやりたいところですが・・・。

Code:
{define-class public AppRecordGridUI {inherits StandardRecordGridUI}
  field protected menu-for-read-only:StringArray =
      {StringArray
          ||非活性にするメニュー
        "昇順ソート",
        "降順ソート",
        "フィルタを取り除く",
        "のみのフィルタ",
        "以下のフィルタ",
        "以上のフィルタ",
        "以外のフィルタ",
        "貼り付け領域",
        "行の固定",
        "を解除",
        "フレームの固定"
||--        ,"貼り付け",
||--        "コピー",
||--        "列の固定"
      }

  field protected menu-for-remove:StringArray =
      {StringArray
        "変更をコミットする",
        "変更を戻す"
      }


  {method public {context-menu-at x:Distance, y:Distance}:#MenuPane
    let menu-pane:#MenuPane = {super.context-menu-at x, y}

    ||メニュー削除用の保持配列
    def delete-menu = {{Array-of MenuAction}}

    ||入力用・表示用のグリッドにあわせてメニューを変更する
    {if-non-null menu-pane then
        {for i:int = 0  below menu-pane.size do

            def menu =  {menu-pane.get i}

            {type-switch menu
             case action:MenuAction do
                def label-string:String = {action.label.get-text}

                ||非活性にしたいラベルの文字列が見つかったら
                ||その MenuAction を無効にする
                {for label in self.menu-for-read-only do
                    {if {label-string.find-string label} > -1 then
                        set action.enabled? = false
                    }
                }

                ||削除したいラベルの文字列が見つかったら
                ||その MenuAction を削除用配列に保持にする
                {for label in self.menu-for-remove do
                    {if {label-string.find-string label} > -1 then
                        {delete-menu.append action}
                    }
                }
            }
        }
    }

    ||削除用配列のメニューを削除する
    {for ma in delete-menu do
        {menu-pane.remove ma}
    }
    {return menu-pane}
  }
}

{let people:RecordSet =
    {RecordSet
        {RecordFields
            {RecordField "First", domain = String},
            {RecordField "Last", domain = String},
            {RecordField "Age", domain = int}
        },
        {RecordData First = "John", Last = "Smith", Age = 25},
        {RecordData First = "Jane", Last = "Smith", Age = 29},
        {RecordData First = "Jane", Last = "Jones", Age = 28}
    }
}
{value
    {RecordGrid
        record-source = people,
        ui-object = {AppRecordGridUI}
    }
}

Forum Jump:


Users browsing this thread:
1 Guest(s)

MyBB SQL Error

MyBB has experienced an internal SQL error and cannot continue.

SQL Error:
1017 - Can't find file: 'mybb_threadviews' (errno: 2)
Query:
INSERT INTO mybb_threadviews (tid) VALUES('493')