Button click on Seesaw (Clojure) not getting new variable values - eclipse

Having a problem with seesaw where i'm trying to let the user select the date using combo boxes and then call the function on a button click:
(listen load-data-btn :action (load-data
(selection year-cmb) (selection month-cmb) (selection day-cmb)))
This works however, the action loads when the program initially runs so whenever the button is clicked it always contains the first value the combo box is selected. So when I click the button it doesn't look for a new value in (selection year-cmb) it just keeps the one it's already got, the default is set to "".
Any idea how I make it so that every time I click the button call it will get the new value inside the combo box?

my problem was that I hadn't encapsulated the value in an (fn [e]) statement like below
(listen load-data-btn :action (fn [e]
(load-data (selection year-cmb) (selection month-cmb) (selection day-cmb))))

Related

Is there a way to execute default TextField key event handler from Action

I have a textfield which has an ancester (maybe multiple) of type Action, which every one of them has a minimum of one ancestor of type Shortcut.
One intent shortcut defined is the one that catches any of the four arrow key pressed.
I want to execute the default TextField behaviour when arrow key pressed is left or right (move cursor left or right) if certain state is present.
Is there a way, once the CallbackAction is executed?
* I know to execute next CallbackAction for that intent with Actions.maybeInvoke<ArrowKeyIntent>(context, intent) but I don't know how to execute default textfield behavior.
Thank you.

Fullcalendar add static events using modal duplicates rendered entries

I am trying to add static "Training"-events using a button located in a modal.
So what should happen: Clicking on a day or a range of days in fullcalendar opens a modal. In this modal a button is available to "add a training event".
I am using this modal because it shall be possible to add other events in future. Not just trainings.
The modal opens fine and clicking the button adds a new entry in fullcalendar. Clicking on a further day opens the modal again. If now the "add a training button" is clicked again, the new event is rendered twice. One event is rendered on the day i have clicked in the first step, the second is rendered at the day i have clicked now.
Step1:
clicking a day opens the modal
Step2:
clicking the button in the modal adds a new entry
Step3: repeating step1 on another day
Step4:
clicking the button again renders the event twice
Image: Step1-4
This is my js-code. What i am doing wrong?
var calendar = $(calendar).fullCalendar({
header: {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay'
},
defaultDate: new Date(),
navLinks: true, // can click day/week names to navigate views
selectable: true,
selectHelper: true,
select: function (start, end) {
$('#fc_create').click(); // opens modal
$('.addTraining').on("click", function () { // clicking "add training button"
var eventData;
eventData = {
title: "Training",
start: start,
end: end
};
$('#calendar').fullCalendar('renderEvent', eventData);
$('.close').click();
})
},
editable: true,
eventLimit: true
});
Every time your "select" callback runs, you are adding another new "click" event handler to the "addTraining" element(s). So if "select" runs 3 times, then the "click" event will be declared 3 times, and when "addTraining" is clicked, 3 versions of the same code will run. Javascript allows multiple handlers for the same event to be attached to an element at once, so you are just building them up each time the "select" callback runs, without ever removing them.
To fix this you can either:
1) Declare the handler once - do it page load, outside your fullCalendar declaration. This will give you a problem in that you won't have direct access to the "start"/"end" values from the select callback. You can get round this by using global variables (yuck) or perhaps putting the values in hidden fields or data- attributes somewhere suitable, and then the click handler can find them each time it runs.
2) Using jQuery's "on" and "off" syntax to first remove the previous handler, and then add a new one, so only one handler is ever active at any one time. See http://api.jquery.com/off/ and http://api.jquery.com/on/ for more details and examples. I can provide a sample if necessary.

Infopath: Rules with Multiple Selection List Box do not trigger

Im trying to implement several rules for a form, based on a selection of some multiple selection list boxes. Im customizing a form for a existing SharePoint list by clicking on "Customize Form" in SharePoint. First of all, the choice fields on the list (multiple selection) are oddly binded in InfoPath:
I cant change the variable's name "Value" and Real Estate Categories should not be a required field. (*)
On one view I have a "Business Unit Purchase" box that is a multiple selection box (choice) and there is a next button. The next button should only be availiable when a selection is made.
So I tried to the following rules for the Next Button:
Rule Type Action:
IF Value (of Business Unit Pruchase) is not blank -> Switch to next view
This works properly, but now i wanted to disable the next button when nothing is the text box was selected, because it makes it more clear to have a selection beofre ist possible to go on. So I tried this:
Rule Type Formatting:
IF Value is blank -> disable this control
This disables the button as wanted when the multiple text box has not any items selected, but after selecting one or more, nothing happens. Is there any reason why this does not work?
Normally when a selection is made, the field "value" of "Business Unit Purchase" should contain one or more strings and therefor should not be blank anymore.
A multiselect list box almost always contains one blank element entry unless it has been manually removed (e.g. via code).
Because of this, the condition Value is blank will almost always be true.
To remedy this, use the dropdown in the Condition builder's field selection dialog to set up your condition as:
All occurrences of Value are blank -> Disable this control
If you do this, the control should be enabled when one or more items are selected.

JQgrid:Get the action from the pager

how can i get the action (what button was clicked) when a button is clicked in the pager?(edit, del, add...)
You probably means button of the navigation bar or navigator (see http://www.trirand.com/jqgridwiki/doku.php?id=wiki:navigator).
You can implement what you want with at least three different ways:
You define your custom buttons which look like the original add/edit/del buttons (see http://www.trirand.com/jqgridwiki/doku.php?id=wiki:custom_buttons) and use {add:false, edit: false, del: off} parameter of navGrid to switch off standard buttons.
You can use addfunc, editfunc and delfunc if you want replace the default add/edit/del functions.
You can use onclickSubmit or afterSubmit or some another supported events (see http://www.trirand.com/jqgridwiki/doku.php?id=wiki:form_editing#events) of add/edit/del button to do some additional action on click the buttont or on submit.
You can chose the way which is the best for your requirements.
You can use the grid onPaging event:
This event fires after click on [page
button] and before populating the
data. Also works when the user enters
a new page number in the page input
box (and presses [Enter]) and when the
number of requested records is changed
via the select box. To this event we
pass only one parameter pgButton
(string) which can be -
first,last,prev,next in case of button
click, records in case when a number
of requested rows is changed and user
when the user change the number of the
requested page.requested page.
Also there are beforeRequest and LoadComplete events. Examples that worked for me are as follows:
beforeRequest: function () {
$.blockUI();
//alert("before request");
},
loadComplete: function () {
//alert("load complete");
$.unblockUI();
}

wxPython: How to handle event binding and Show() properly

I'm just starting out with wxPython and this is what I would like to do:
a) Show a Frame (with Panel inside it) and a button on that panel.
b) When I press the button, a dialog box pops up (where I can select from a choice).
c) When I press ok on dialog box, the dialog box should disappear (destroyed), but the original Frame+Panel+button are still there.
d) If I press that button again, the dialog box will reappear.
My code is given below. Unfortunately, I get the reverse effect. That is,
a) The Selection-Dialog box shows up first (i.e., without clicking on any button since the TopLevelframe+button is never shown).
b) When I click ok on dialog box, then the frame with button appears.
c) Clicking on button again has no effect (i.e., dialog box does not show up again).
What am I doing wrong ? It seems that as soon as the frame is initialized (even before the .Show() is called), the dialog box is initialized and shown automatically.
I am doing this using Eclipse+Pydev on WindowsXP with Python 2.6
============File:MainFile.py===============
import wx
import MyDialog #This is implemented in another file: MyDialog.py
class TopLevelFrame(wx.Frame):
def __init__(self,parent,id):
wx.Frame.__init__(self,parent,id,"Test",size=(300,200))
panel=wx.Panel(self)
button=wx.Button(panel, label='Show Dialog', pos=(130,20), size=(60,20))
# Bind EVENTS --> HANDLERS.
button.Bind(wx.EVT_BUTTON, MyDialog.start(self))
# Run the main loop to start program.
if __name__=='__main__':
app=wx.PySimpleApp()
TopLevelFrame(parent=None, id=-1).Show()
app.MainLoop()
============File:MyDialog.py===============
import wx
def start(parent):
inputbox = wx.SingleChoiceDialog(None,'Choose Fruit', 'Selection Title',
['apple','banana','orange','papaya'])
if inputbox.ShowModal()==wx.ID_OK:
answer = inputbox.GetStringSelection()
inputbox.Destroy()
There are a number of ways to do this, but to make the least number of changes to your code,
Change def start(parent): to
def start(parent, evt):
And change button.Bind(wx.EVT_BUTTON, MyDialog.start(self)) to
button.Bind(wx.EVT_BUTTON, lambda evt: MyDialog.start(self, evt))
That is, the second argument in Bind needs to be a function that takes and event, and you need to create the dialog box when the button is clicked. lambda makes this a function that also takes parent and evt (you can also use functools.partial for version >2.5), and then when the button is clicked, start will be called to create the dialog.
I'm not quite sure what's going on in your code, but it seems that you're calling start and creating the dialog in your initial call to Bind, and then passing the return value from start, None to Bind.
Note 1
In more detail, the reason to use the lambda here is that Bind should have a form like Bind(event, handler) where event is a wx.PyEventBinder, like wx.EVT_BUTTON, and handler is a function like foo(evt) where evt is a wx.Event or wx.CommandEvent. (There's no recursion here, as you're just saying what to do when something happens, but that thing hasn't happened yet, so the event hasn't been created. When the event does happen, it will be represented by a wx.Event, which will have information about the event, like where the mouse was when it was clicked, etc.)
Note 2
In my answer I tried to answer your question with minimal changes as I thought that would be easiest. Maybe the code below is more clear (and maybe it's generally clearest to handle events within the widget that creates them):
def start2(parent):
inputbox = wx.SingleChoiceDialog(parent,'Choose Fruit', 'Selection Title',
['apple','banana','orange','papaya'])
if inputbox.ShowModal()==wx.ID_OK:
answer = inputbox.GetStringSelection()
inputbox.Destroy()
class TopLevelFrame2(wx.Frame):
def __init__(self,parent,id):
wx.Frame.__init__(self,parent,id,"Test",size=(300,200))
panel=wx.Panel(self)
button=wx.Button(panel, label='Show Dialog', pos=(130,20), size=(60,20))
# Bind EVENTS --> HANDLERS.
button.Bind(wx.EVT_BUTTON, self.OnClick)
def OnClick(self, evt):
start2(self)