In my iPad app, there is a UIWebview that displays text content. When I tap hold and select a text, a menu should popup with 2 custom menu.
say, | MENU1 | MENU2 |
But it seems the COPY menu will also accompany, which I couldn't disable. Is there any possibilities to disable it? I tried around the forum and no solutions worked out.
so itz okay to keep the COPY menu along with the other 2. which should now look like
| Copy | MENU1 | MENU2 |
But unfortunately, I 'm getting it displayed with a MORE menu as follows :
| Copy | More... |
Clicking the More... menu is showing the other 2 menu.
But I need all those 2 items to be displayed in the first attempt itself. either just the 2 menus alone, or atleast along with the copy menu.
| Copy | MENU1 | MENU2 |
OR
| MENU1 | MENU2 |
Get me some solution please.... Trying it out in many ways.. But nothing is working out...
Plz help me out...
Thanks,
Brian
It doesn't appear that there is a way to do this without replacing the UIMenuController. One option is to handle your own UILongPressGestureRecognizer (see How to remove th COPY UIMenuItem in UIMenuController). I've seen proposals where you override canPerformAction, but this does not work. Interestingly, the "copy:" action is never called, though it seems that everything else (cut:,select:,etc.) is.
- (BOOL) canPerformAction:(SEL)action withSender:(id)sender
{
if (action == #selector(defineSelection:))
{
return YES;
}
else if (action == #selector(translateSelection:))
{
return YES;
}
else if (action == #selector(copy:))
{
return NO;
}
return [super canPerformAction:action withSender:sender];
}
`
Related
My question is in android programming in android studio.
I can hide navigation bar but when dropdown spinner , it show again.
Besides that when i tap on EditText , revealing the softkeyboard will cause the navigation bar to reappear.
how can solve it?
(I searched a lot but could not find the correct answer)
call this method in onCreate , onResume and onWindowFocusChanged
private void hideNavigationBar() {
View decorView = getWindow().getDecorView();
int uiOptions = View.SYSTEM_UI_FLAG_IMMERSIVE
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_FULLSCREEN
| View.SYSTEM_UI_FLAG_LOW_PROFILE
| View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_LAYOUT_STABLE;
decorView.setSystemUiVisibility(uiOptions);
}
In MFC how to remove a menu-item of POPUP type. RemoveMenu() either take ID or position. Since, there is no ID for POPUP menu, option left is by using position.
But I am not getting how and where I can call RemoveMenu().
File Edit Test
Test_submenu_1
Test_submenu_2
Test_submenu_3 > submenu_3_item_1
Test_submenu_4
Test_submenu_5
I want to remove Test_submenu_3? I am not getting how do find CMenu object for Test so that I can call RemoveMenu() by passing position "2" for submenu_3_item_1.
Any suggestion for doing this will be greatly appreciated.
Thanks!
You cannot use LoadMenu, since this function does just that.
After modifying loaded menu it is killed when menu object used to load it goes out of scope. You have to modify menu that is currently used.
Your menu is a popup part of the main menu, second in position. It contains 5 items and second one is another popup. To my understanding, you want to remove this item and popup of this item.
To make it work you will have to ask main window for the current menu:
CMenu* pMenu = GetMenu(); // get the main menu
CMenu* pPopupMenu = pMenu->GetSubMenu(2);//(Test menu with item....)
pPopupMenu->RemoveMenu(2, MF_BYPOSITION);
Of course, this code is from the main frame. If you want to use it elsewhere, you will have to access all using pointer to the main frame.
Try the below. You get the Test sub-menu first (index 2), then once you have that you tell it to remove its Test_submenu_3 submenu by position (also 2).
CMenu topMenu;
topMenu.LoadMenu(IDR_YOUR_MENU);
CMenu& testSubMenu = *topMenu.GetSubMenu(2);
testSubMenu.RemoveMenu(2,MF_BYPOSITION);
'Test' is the 3rd menu item (by position) on the top level menu. It's just been rendered horizontally rather than vertically. Assuming you have a handle to the top level menu use the same code you'd use to the get the sub menus as you would to get the 'Test' menu.
You can use this below code to remove the submenu, by comparing name
bool RemoveSubmenu(CMenu * pMenu) {
for (int pos = 0; pos < pMenu->GetMenuItemCount(); pos++) {
wchar_t *name = new wchar_t[mf.cch + 1];
MENUITEMINFO mf;
ZeroMemory(&mf, sizeof(mf));
mf.cbSize = sizeof(mf);
mf.fMask = MIIM_SUBMENU | MIIM_FTYPE | MIIM_STRING;
mf.fType = MIIM_STRING;
mf.dwTypeData = NULL;
if (!GetMenuItemInfo(pMenu->m_hMenu, pos, TRUE, &mf))
break;
if (mf.hSubMenu != NULL){
mf.fMask = MIIM_TYPE;
mf.fType = MFT_STRING;
++mf.cch;
mf.dwTypeData = (LPSTR)name;
if (!GetMenuItemInfo(pMenu->m_hMenu, pos, TRUE, &mf)){
bRet = false;
break;
}
//
// compare sub menu name (i.e mf.dwTypeData) here, do the required
// modifications
//
pMenu->RemoveMenu(pos, MF_BYPOSITION);
bRet = true;
break;
}
}
}
How could I Add Minimize and Maximize box to the system menu of CMFCPropertySheet.
I have tried modifying the style by
CMFCPropertySheet::ModifyStyle(NULL, WS_SYSMENU);
but nothing happened.
Assuming you have a class derived from CPropertySheet, let's call it MySheet:
// Capture the WM_NCREATE message
BEGIN_MESSAGE_MAP(CMySheet, CPropertySheet)
ON_WM_NCCREATE()
END_MESSAGE_MAP()
BOOL CMySheet::OnNcCreate(LPCREATESTRUCT lpCreateStruct)
{
if (!CPropertySheet::OnNcCreate(lpCreateStruct))
return FALSE;
// Modify the window style
LONG dwStyle = ::GetWindowLong(m_hWnd, GWL_STYLE);
::SetWindowLong(m_hWnd, GWL_STYLE, dwStyle | WS_WS_MINIMIZEBOX | WS_MAXIMIZEBOX);
return TRUE;
}
Note that you could do this in the OnInitDialog, but even though the Minimize/Maximize boxes will show, they won't do anything.
doing just this in the "OnInitDialog:" worked for me.
LONG dwStyle = ::GetWindowLong(m_hWnd, GWL_STYLE);
::SetWindowLong(m_hWnd, GWL_STYLE, dwStyle | WS_WS_MINIMIZEBOX | WS_MAXIMIZEBOX);
Im using W7, VS2010: create an MDI app with the visual studio look so it has a COutputWnd inherited from CDockablePane at the bottom. Copying the default I've made a new tab, but inherited from CEdit. The tabs inherited from CListBox work great with the following styles:
const DWORD dwStyle = LBS_NOINTEGRALHEIGHT | WS_CHILD | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL;
But the CEdit with the following does not scroll vertically:
const DWORD dwStyle2 = WS_CHILD | WS_VISIBLE | WS_BORDER | WS_VSCROLL | ES_MULTILINE | ES_AUTOVSCROLL;// | ES_READONLY;
I've tried all combinations of the above styles and read tons of websites, but nothing works :(
Oh - and I do have ShowWindow(SW_SHOW);
Thanks for any help you can offer.
Ta-da! Got it sorted. In COutputWnd::OnCreate I had used this as the parent window:
m_wndVehicle->Create(dwStyle2, rectDummy, this, 3);
It should have been &m_wndTabs:
m_wndVehicle->Create(dwStyle2, rectDummy, &m_wndTabs, 3);
Works a treat now!
Hope it saves someone else 2 hours!
I would like to show a list of panels containing components, i.e a checkbox, labels, buttons, all on the same horizontal line; each panel represents one set of components to display information for one item.
I need to put the list of panels (number undetermined) inside a scrollpanel to fit within the main panel height.
I can't seem to find a solution for mixing scrollpanel and panels with components.
I'd like to get this result :
scrollpanel {
checkbox | item1 | button1 | button1 | label1 | label1
checkbox | item2 | button2 | button2 | label2 | label2
checkbox | item3 | button3 | button3 | label3 | label3
[ ... ]
}
There is a working example of what I have currently shown here :
Groovy SwingBuilder : button to change the color of a panel
There, you can see there are 6 items, each one with their respective components relating to it.
Now if I wanted to display 60 items instead of 6, the frame would expand to fit them but exceed the screen size.
I seems so obvious to me that kind of a "scrollpanel" would do the job, but I can't get it working, although I checked all examples on the Java tutorials and the related questions here.
tia.
Michel
You can put the panels inside a vbox, which in-turn you put inside a scrollPane.
Taking the code from the previous question, you end up with something like this:
import groovy.swing.SwingBuilder
import javax.swing.WindowConstants as WC
import javax.swing.JOptionPane
import javax.swing.JScrollPane
import javax.swing.BoxLayout as BXL
int numPanels = 20
swing = new SwingBuilder()
frame = swing.frame(title:'test', pack:true, visible:true, defaultCloseOperation:WC.HIDE_ON_CLOSE) {
panel(id:'mainPanel'){
scrollPane( verticalScrollBarPolicy:JScrollPane.VERTICAL_SCROLLBAR_ALWAYS ) {
vbox {
(1..numPanels).each { num ->
def panelID = "panel$num"
def pane = panel( alignmentX:0f, id:panelID, background:java.awt.Color.GREEN ) {
label('description')
textField( id: "description$num", text:panelID, columns: 70 )
button( id: "buttonpanel$num", text:panelID, actionPerformed:{
swing."$panelID".background = java.awt.Color.RED
} )
}
}
}
}
boxLayout(axis: BXL.Y_AXIS)
panel(id:'secondPanel' , alignmentX: 0f){
button('Quit', actionPerformed:{
frame.visible = false
})
}
}
}
frame.size = [ frame.width, 600 ]