I have a GUI where some values are displayed in an editable text box . For some reason, I cannot copy these values with the mouse. I can select the text, but no drop-down menu appears when I right-click on the selected text. I searched everywhere. What am I missing?
It is true that editable text fields do not by default invoke a context menu when you right-click, but there are several ways to get around this if you want to copy text to the clipboard:
As Mikhail mentions in his comment, you can still select the text and press Ctrl+ Cto copy it to the clipboard.
As Itamar mentions in his answer , you can create your own context menu for an editable text field using the UICONTEXTMENU and UIMENU functions . Here's an example implementation that uses the CLIPBOARD function to add an editable text string to the clipboard:
hFigure = figure; %# Create a figure hEdit = uicontrol(hFigure,'Style','edit',... %# Create an editable text box 'String','Enter your name here',... 'Position',[30 50 130 20]); hCMenu = uicontextmenu; %# Create a context menu uimenu(hCMenu,'Label','Copy',... %# Create a menu item 'Callback',@(hObject,eventData) clipboard('copy',get(hEdit,'String'))); set(hEdit,'UIContextMenu',hCMenu); %# Add context menu to control
, : "". , , , , .
'ButtonDownFcn' , , . m :
'ButtonDownFcn'
function right_click_copy(hObject,eventData) hFigure = get(hObject,'Parent'); %# Get the parent object while ~strcmp(get(hFigure,'Type'),'figure') %# Loop until it is a figure hFigure = get(hFigure,'Parent'); %# Keep getting the parents end if strcmp(get(hFigure,'SelectionType'),'alt') %# Check for a right click clipboard('copy',get(hObject,'String')); %# Copy the object string to %# the clipboard end end
'SelectionType' , , , CLIPBOARD, . :
'SelectionType'
hFigure = figure; %# Create a figure hEdit = uicontrol(hFigure,'Style','edit',... %# Create an editable text box 'String','Enter your name here',... 'Position',[30 50 130 20],... 'ButtonDownFcn',@right_click_copy);
, , .
, , uicontextmenu uicontrol uimenu. . : http://www.mathworks.com/help/techdoc/ref/uicontextmenu.html
uicontextmenu
uimenu
"Enable"?
(handles.editbox1, 'Enable', 'on');
(assuming you have a handle to this GUI object.)
This should make the editable field editable.
Source: https://habr.com/ru/post/1779977/More articles:Generate code snippet for functions in VS2010 - c #Strange extra height div in google chrome - javascriptSilverlight / WPF Programming with Windows Forms Skills - .netWhich one is better? do {} while (0); or goto xy; - cRead-only lock in SQL Server - sql-serverCQRS & ElasticSearch - using ElasticSearch to create a reading model - elasticsearchСбой при связывании при добавлении другого свойства - wpfrails: fields_for and collection - ruby | fooobar.comhttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1779981/connect-validatesexclusionof-bad-words-to-a-separate-file&usg=ALkJrhhcZ4e_dyCVhgwLZJ7X0O0rIi98pAImplementing Admob in Phonegap for Android - androidAll Articles