Kivymd dropdown closes immediately after opening - drop-down-menu

I am trying to add a dropdown list using kv file. I have managed to create it but when i click on it the drop down opens and closes immediately without me selecting or clicking anywhere
How do i stop this
Button:
id: btn
text: 'Press'
on_release:
if not root.state: dropdown.open(self); root.state = False
else: dropdown.dismiss(); root.state = False
size_hint: 0.2,0.05
height: '48dp'
DropDown:
id: dropdown
on_parent: self.dismiss()
on_select: btn.text = '{}'.format(args[1]); root.state = False
Button:
text: 'First Item'
size_hint_y: None
height: '48dp'
on_release: dropdown.select('First Item')
Label:
text: 'Second Item'
size_hint_y: None
height: '48dp'
Button:
text: 'Third Item'
size_hint_y: None
height: '48dp'
on_release: dropdown.select('Third Item')

If you're talking about MDDropDownMenu - it is working another way and accepts list of dicts for the buttons. Here's the example:
In kv file:
MDRaisedButton:
text: app.groupstrace
size_hint_x: 0.15
# here you call drop down menu:
on_release: MDDropdownMenu(items=app.groupsdict, width_mult=3, background_color=[1,0.5,0,1]).open(self)
md_bg_color: [1,0.5,0,1]
In .py file:
groupsdict = [
{
"viewclass": "MDMenuItem",
"text": "Yourtext",
# no parentheses after function name!
"callback": self.function1,
},
{
"viewclass": "MDMenuItem",
"text": "Yourtext",
# in case you want label, just don't set a callback
"callback": None,
}
# and so on
]

Related

Electron OSX application menu - how to add custom File menu?

I have an app (based on a magazine tute) with a menu that works fine on Windows and Ubuntu, but I have trouble getting the app level custom menu items to appear on MacOS. These menu items are File and View entries.
I have pored over the electron API docs and I see the special considerations for OSX, especially about the "role" attribute, but I am still stymied here. I am able to create menu items on OSX for the types of things listed in the API documents (such as "Edit" menu items using role, from a Renderer script) but not for my app.
Could my menu items be colliding with reserved "File/View" menu item names in the mac menu?
Here's the snip with my menu template string:
var SendEvent = function(name) {
return function() {win.webContents.send(name);};
};
var template = [
{label: 'File', submenu: [
{label: 'New', click: SendEvent('file-new')},
{label: 'Open', click: OpenFile},
{label: 'Save', click: SendEvent('file-save')},
{label: 'Save As', click: SendEvent('file-save-as')},
{label: 'Close', click: SendEvent('file-close')},
{type: 'separator'},
{label: 'Quit', click: function() {app.quit();}}
]}, {label: 'View', submenu: [
{label: 'HTML/Markdown', click: SendEvent('view-toggle')}
]}
];
Menu.setApplicationMenu(Menu.buildFromTemplate(template));
Are there any other examples out there of apps with custom File and View menu actions that work on macOS?
Menu.setApplicationMenu(Menu.buildFromTemplate(template));
should be called within createWindow() function:
function createWindow() {
mainWindow = new BrowserWindow({
width: 800,
height: 600
})
mainWindow.loadURL(url.format({
pathname: path.join(__dirname, "index_menus.html"),
protocol: "file:",
slashes: true
}))
mainWindow.on("closed", () => {
mainWindow = null;
});
var template = [
{label: 'File', submenu: [
{label: 'New', click: SendEvent('file-new')},
{label: 'Open', click: SendEvent('file-open')},
{label: 'Save', click: SendEvent('file-save')},
{label: 'Save As', click: SendEvent('file-save-as')},
{label: 'Close', click: SendEvent('file-close')},
{type: 'separator'},
{label: 'Quit', click: function() {app.quit();}}
]},
{label: 'View', submenu: [
{label: 'HTML/Markdown', click: SendEvent('view-toggle')}
]}
];
Menu.setApplicationMenu(Menu.buildFromTemplate(template));
}
If you use "File" menu, it will be placed under YourAppName menu (the first one) on macOS.

Add title to kendo ui grid

After researching on the web, i´m facing a problem on adding a title into my grid, so my code is:
.html file:
<div id="idGridTiposQuartos" class="gridtiposquartos js-var-grid-tipos-quartos">
<div id="gridTiposQuartos">
</div>
</div>
.js file:
$("#idBtnTiposQuarto").click(function()
{
$("#idGridTiposQuartos").fadeIn(1000);
$("#idBtnQuartos").attr("disabled", false);
$(".k-grid-toolbar", "#gridTiposQuartos").before("<h1>hello</h1>");
$(".k-grid-toolbar", "#gridTiposQuartos").after("<h1>hello</h1>");
(some more code)
$("#gridTiposQuartos").kendoGrid({
dataSource: dataSource,
pageable:
{
messages:
{
display: "{0} - {1} / {2} items",
empty: "0 items",
page: "Page",
of: "of {0}", //{0} is total amount of pages
itemsPerPage: "items per page",
first: "Go to the first page",
previous: "Go to the previous page",
next: "Go to the next page",
last: "Go to the last page",
refresh: "Refresh"
}
},
serverPaging: true,
height: 460,
toolbar:[{name: "create",text: $varGridQuartosBtnNovoPT},{name: "close",text: "X"}],
columns:[{ field:"Nome", title: "Nome" },{ field: "Preco", title:"Preço", format: "{0:c}", width: "100px" },
{command:[{ name: "edit",text:{edit:$varGridQuartosBtnEditarPT,update:$varGridQuartosBtnActualizarPT,cancel:$varGridQuartosBtnCancelarPT}},{ name: "destroy",text:$varGridQuartosBtnApagarPT }],title:" ",width: "230px"}],
editable : {mode : "popup",
window : {title: "Editar",}
(the rest of the code)
I think i have posted the necessary code to show my problem, so my question is, what am i missing here?. any help? thanks.

How to remove cancel button from jqgrid add form?

jqgrid add dialog have two buttons(submit and cancel). A message will be displayed when i click the cancel button. That message box have 3 buttons(yes, no and cancel). Now i want to remove the cancel button. any possibilities........?
Sorry for my bad english.
Thank you.
sample coding for jqgrid
<sjg:grid id="gridtable"
caption="Customer List"
dataType="json"
href="%{remoteurl}"
pager="true"
gridModel="customerList"
rowNum="10"
autowidth="true"
editurl="%{editurl}"
editinline="false"
navigator="true"
navigatorAdd="true"
navigatorAddOptions="{
viewPagerButtons: false,
recreateForm: true,
checkOnUpdate: true,
closeAfterAdd: true,
height: 275,
width: 600,
draggable: false,
resizable: false
}"
navigatorDelete="true"
navigatorEdit="true"
navigatorRefresh="true"
navigatorSearch="true"
navigatorEditOptions="{
viewPagerButtons: false,
recreateForm: true,
checkOnUpdate: true,
closeAfterEdit: true,
height: 275,
width: 600,
draggable: false,
resizeable: false
}"
navigatorDeleteOptions="{ checkOnUpdate: true}"
navigatorViewOptions="{
viewPagerButtons: false,
recreateForm: true,
checkOnUpdate: true,
height: 225,
width: 620,
draggable: false,
resizeable: false
}"
navigatorSearchOptions="{
sopt:['eq','ne','lt','gt','in','ni','cn','nc'],
closeAfterSearch: true
}"
navigatorView="true"
rownumbers="true"
rowList="10,20,30"
viewrecords="true"
>
Thank you so much.
Here i am specifing that cancel button
how to remove this cancel button?
I need only yes and no buttons.
Using grid API how it can be possible i dont know but,using jquery you can hide this button in following way :
$("#gridtable #cNew).css({'display':'none'});
'#cNew' is id of that button or you can get id of Cancle button by right click on that button and select inspect element in mozila webbrowser or use firebug to get id of that button and then replace that id with #cNew.
I think you can apply it to each form add, edit, etc.
hide button cancel
onInitializeForm: function($form) {
$form.parent().find('#cData').hide();
}
or if you want hide button submit
beforeShowForm: function ($form) {
$form.parent().find('#sData').hide();
},

In Sencha Touch how can I push to a new view when clicking a button?

I have the following button within a Panel within a view:
items: [
{
xtype: 'button',
text: 'SEND',
ui: 'confirm',
docked: 'bottom',
handler: function(){
view.push('TouchNuts.view.Transactions',{
title: 'New views title',
html: 'Some content'
});
}
}
]
I would like to navigate to a page that consists of a list 'TouchNuts.view.Transactions' when I click it. Any ideas?
view needs to be a reference to your NavigationView. One way of getting that reference is by giving it an id and then using Ext.getCmp to fetch the component:
{
xtype: 'navigationview',
id: 'my-id',
items: [...]
}
Ext.getCmp('my-id');

Prevent word wrap in error message

I have weird situation that extjs 4 always puts last word of custom error message in new row, and effectively hides it. I tried shortening message, but always last word goes to new line. This happens in Firefox 7.0.1 (firebug turned off), not in Chrome, Opera, Safari.
Default message text is displayed correctly. My error message has no strange letters or symbols.
I tried escaping white characters, putting nobr tags etc... but nothing works.
How to prevent this behavior?
I have no any css or any other styling applied. Here is code from view:
this.items = [{
waitMsgTarget: 'dailyReport',
xtype: 'form',
url: 'php/dailyReport.php',
items: [{
margin: 10,
xtype: 'datefield',
name: 'reportDate',
fieldLabel: 'Report for',
format: 'd.m.Y.',
altFormats: 'd.m.Y|d,m,Y|m/d/Y',
value: getCorrectDate(),
disabledDays: [0]
},
{
margin: 10,
xtype: 'checkboxgroup',
fieldLabel: 'Report by',
columns: 2,
vertical: true,
allowBlank: false,
blankText: 'Choose at least one.',
items: [{
boxLabel: 'pos',
name: 'rb',
inputValue: '1',
checked: true
},
{
boxLabel: 'seller',
name: 'rb',
inputValue: '2',
checked: true
}]
}]
}];
'Ctrl' + '+' was reason. My view in Firefox was zoomed in, but I didn't notice it until today. After I returned it to normal zoom level 'Ctrl' + '0' everything works and shows up fine. Silly me, it took me 2 weeks to realize this.

Resources