I can write
wxPropertyGrid * pg;
...
wxStringProperty * pA = new wxStringProperty("A",
wxPG_LABEL,"");
wxStringProperty * pB = new wxStringProperty("B",
wxPG_LABEL,"");
pg->Append( pA );
pg->Append( pB );
pg->SetPropertyEditor( pA, wxPGEditor_TextCtrlAndButton );
pg->SetPropertyEditor( pB, wxPGEditor_TextCtrlAndButton );
Bind( wxEVT_COMMAND_BUTTON_CLICKED,
&cFrame::OnPropertyButton, this );
...
void cFrame::OnPropertyButton( wxCommandEvent& event )
{
wxMessageBox(wxString::Format("button %d", event.GetId()));
}
and it works, quite well - the button message pops up when I click on the button in either property A or B
But, how do I distinguish, in the event handler, between clicks on A and B.
Normally, I would get the button id from the event, but these buttons do not appear to have IDs - the message shows the same ID for both.
I found that I can grab the label from the currently active property, and so use that to make the distinction
void cFrame::OnPropertyButton( wxCommandEvent& event )
{
wxMessageBox(wxString::Format("button %s",
pg->GetSelection()->GetLabel()));
}
Related
I have a piece of code working as expected in Android but not in iOS. Problem is the value of the final variable 'nombre' which in Android gets the expected value, whereas in iOS it gets a different one randomly chosen from the list (specified in codesnippet provided)
public AsignarNombreCDF(){
this.departamentoId = AdministradoresApp.departamentoId;
this.setLayout(BoxLayout.y());
this.setTitle("Asignar Nombre a CDF");
TopBarUtils.addMenuToTopbar(this);
TopBarUtils.addCommandToTopbarMenu(this, "Inicio Departamento", e->{new MenuDepartamento(departamentoId).show();});
try {
Map m = Utils.consultaWebService("newfoldernames", new Object[]{"department", departamentoId});
String folderNameMatrix = (String) m.get("FolderNameMatrix");
Map m_ = (Map) JSONUtils.fromJsonString(folderNameMatrix);
Iterator it = m_.keySet().iterator();
while(it.hasNext()){
String k = (String) it.next();
final String nombre = (String) m_.get(k);
Button b = new Button(nombre);
b.addActionListener(e->{cargarFotos(nombre);});
this.add(b);
}
int y = 2;
} catch (Exception ex) {
Utils.gestionaExceptionUi(ex);
}
}
Problem is that the final variable nombre seems not to assign correctly to the value passed to the button listener. This as already said, only happens in IOS and not in Android, where we never get a mismatch. Any chance that the iOS build system might oversee this situation?. Any ideas how to overcome the problem?
Regards.
Carlos.
Is there a way to handle Gecko.DOM.GeckoInputElement click event?
I have a submit button in a tag and I'd like to rise an event when I click it with the mouse. The website is open in a Gecko Browser.
I'm useing xulrunner-29.0b2.en-US.win32 and GeckoFx-Windows-29.0-0.1
My code is:
Friend WithEvents inputElement As Gecko.DOM.GeckoInputElement
Private Sub inputElement_click() Handles inputElement.Click
MsgBox("a")
End Sub
but obviously "inputElement.Click" doesn't exists.
The easiest way to do this is to add a DomClick Handler to the main control.
C#
browser.DomClick += click;
Then inside the handler look for your button and responded appropriately.
C#
click( object sender, DomEventArgs e )
{
if ( sender == null ) return;
if ( e == null ) return;
if ( e.Target == null ) return;
var element = e.Target.CastToGeckoElement();
GeckoHtmlElement clicked = element as GeckoHtmlElement;
if ( clicked == null ) return;
if ( clicked.TagName.ToLowerInvariant() == "input" && clicked.GetAttribute("type").ToLowerInvariant() == "submit" )
{
e.Handled = true;
MessageBox.Show("a");
}
I am trying to animate an image based on the select pivoted items position.
I am currently using the ManipulationDelta event to try and see which direction the user is swiping so that I can fade out or fade in an animated image based on the position of the pivot item.
My problem is with the ManipulationDelta event, this event is only ever called once on a pivot item, regardless of how much manipulation of the pivot control is occurring.
Does anyone know a way to make it so the pivot items ManpulationDelta event is constantly called when it is being manipulated?
Probably your Pivot is intercepting further events. You may try to do such a thing - disable Pivot (then your Manipulations should work) and change PivotItems manually for example using TouchPanel and Touch.FrameReported. Sample code:
public MainPage()
{
InitializeComponent();
myPivot.IsHitTestVisible = false; // disable your Pivot
Touch.FrameReported += Touch_FrameReported;
TouchPanel.EnabledGestures = GestureType.HorizontalDrag;
}
TouchPoint first;
private const int detectRightGesture = 20;
private void Touch_FrameReported(object sender, TouchFrameEventArgs e)
{
TouchPoint mainTouch = e.GetPrimaryTouchPoint(this);
if (mainTouch.Action == TouchAction.Down)
first = mainTouch;
else if (mainTouch.Action == TouchAction.Up && TouchPanel.IsGestureAvailable)
{
if (mainTouch.Position.X - first.Position.X < -detectRightGesture)
{
if (myPivot.SelectedIndex < myPivot.Items.Count - 1) myPivot.SelectedIndex++;
else myPivot.SelectedIndex = 0;
}
else if (mainTouch.Position.X - first.Position.X > detectRightGesture)
{
if (myPivot.SelectedIndex > 0) myPivot.SelectedIndex--;
else myPivot.SelectedIndex = myPivot.Items.Count - 1;
}
}
}
My code can be found here: http://pastebin.com/tmzGgHzi
Basically, what my critter does is it selects a random location and moves to that location, eating all actors in its path. However, the second I click "step", it throws a NullPointerException on line 67. It's something with the getAdjacentLocation() method referencing a null object, but I can't figure it out, and neither can my AP teacher.
Any help is greatly appreciated! Thanks!
The getLocation() method is returning null.
Location loc = this.getLocation();
//Loc is now null, so the following call will result in a null pointer exception
Location newLoc = loc.getAdjacentLocation(getDirection());
This is because it's removing itself from the grid/it's eating itself
public ArrayList<Actor> getActors(){
ArrayList<Actor> list = new ArrayList<Actor>();
Grid<Actor> gr = getGrid();
Location loc = getLocation();
atLocation = atRandomLocation();
if(!atLocation){
setDirection(loc.getDirectionToward(randomLocation));
//THIS RETURNS THE CRITTER'S CURRENT LOCATION!
Actor a = gr.get(getLocation());
if(a != null)
//This critter is not going to be null, so it adds it to the list
list.add(a);
}else
getRandomLocation();
//This list contains all actors to be eaten
return list;
}
What your method does is check if it's at the location, adds itself to the list, and then EATS ITSELF!
public void processActors(ArrayList<Actor> actors){
for(Actor a : actors)
//This list only contains the critter
a.removeSelfFromGrid();
}
What you need to do is find the next location it should move to, eat any actors in that space, and then move in.
P.S. Apparently a Critter will eat itself by default if it's the only actor.
I'm trying to use a GWT 2.5rc1 custom tablebuilder to render a subtable for each row in my datagrid. I've followed the example in the 2.5 rc1 showcase (url: http://showcase2.jlabanca-testing.appspot.com/#!CwCustomDataGrid).
I'm able to see the newly added sub-rows, but the problem comes when I want to add a clickhandler to a subrow anchor element.. the clickhandler is never invoked, which it seems also quite clear to me since I'm not "registering" the event handler anywhere.
Here the code I'm using now, "relevant part":
private void buildRegRow(Registrazione rowValue,final int absRowIndex, boolean isCommentRow) {
// Calculate the row styles.
SelectionModel<? super Registrazione> selectionModel = cellTable.getSelectionModel();
boolean isSelected =
(selectionModel == null || rowValue == null) ? false : selectionModel
.isSelected(rowValue);
boolean isEven = absRowIndex % 2 == 0;
StringBuilder trClasses = new StringBuilder(rowStyle);
if (isSelected) {
trClasses.append(selectedRowStyle);
}
// Calculate the cell styles.
String cellStyles = cellStyle;
if (isSelected) {
cellStyles += selectedCellStyle;
}
if(isCommentRow)
cellStyles += childCell;
TableRowBuilder row = startRow();
row.className(trClasses.toString());
/*
* Checkbox column.
*
* This table will uses a checkbox column for selection. Alternatively,
* you can call dataGrid.setSelectionEnabled(true) to enable mouse
* selection.
*/
TableCellBuilder td = row.startTD();
td.className(cellStyles);
td.style().outlineStyle(OutlineStyle.NONE).endStyle();
if (!isCommentRow) {
renderCell(td, createContext(0), cellTable.getColumn(0), rowValue);
}
td.endTD();
/*
* View children column.
*
* Displays a link to "show children". When clicked, the list of friends is
* displayed below the contact.
*/
td = row.startTD();
td.className(cellStyles);
if(!isCommentRow) {
td.style().outlineStyle(OutlineStyle.NONE).endStyle();
if(rowValue.hasComments())
//td.className(CellTableResource.INSTANCE.dataGridStyle().showChildren());
renderCell(td, createContext(1), cellTable.getColumn(1), rowValue);
} else {
td.colSpan(getColumns().size() - 1);
// // Draw sub-table header
TableBuilder subTable = td.startTable();
TableSectionBuilder subTableSection = subTable.startTHead();
TableRowBuilder tr2 = subTableSection.startTR();
TableCellBuilder td2 = tr2.startTH();
td2.text(msgs.date());
tr2.endTH();
td2 = tr2.startTH();
td2.text(msgs.username());
tr2.endTH();
td2 = tr2.startTH();
td2.text(msgs.comment());
tr2.endTH();
td2 = tr2.startTH();
td2.text(msgs.actions());
tr2.endTH();
subTableSection.endTR();
subTable.endTHead();
subTableSection = subTable.startTBody();
for(final EntityComment ec : rowValue.getCommentList()) {
tr2 = subTableSection.startTR();
// Date
td2 = tr2.startTD();
td2.text(DateUtil.getDefaultDateTimeFormat().format(ec.getCreationDate()));
tr2.endTD();
// Username
td2 = tr2.startTD();
td2.text(ec.getUsername());
tr2.endTD();
// Text
td2 = tr2.startTD();
td2.text(ec.getText());
tr2.endTD();
// Actions
td2 = tr2.startTD();
// Remove
Anchor removeAnchor = new Anchor("remove");
removeAnchor.addClickHandler(new ClickHandler() {
#Override
public void onClick(ClickEvent event) {
Window.alert("clicked");
}
});
td2.html(new SafeHtmlBuilder().appendHtmlConstant(removeAnchor.toString()).toSafeHtml());
tr2.endTD();
subTableSection.endTR();
}
subTable.endTBody();
td.endTable();
}
td.endTD();
for(int i = 2; i <= 6; i++) {
// Recorded, list name, callcenter, msisdn
td = row.startTD();
td.className(cellStyles);
td.style().outlineStyle(OutlineStyle.NONE).endStyle();
if(!isCommentRow) {
renderCell(td, createContext(i), cellTable.getColumn(i), rowValue);
}
td.endTD();
}
row.endTR();
}
The subtable shows up, with an anchor at the correct position, but the clickhandler is never invoked. I do not know how to write the handler code to the page, like I've done to render the anchor.
Thanks for any help.
I have tried custom tablebuilder and created a grid. You can add any element using the proper structure. Make sure you set the Unique Id to each element you create. Then through code access the element through the following code,
Element e = DOM.getElementById( id );
Cast the element to its proper widget i.e, if you are using text input element you can always cast it to textbox. To cast the element there is one more step which you can google out. Then add the clickhandler or whichever handler you want.