Default Attr for a wxSheet cell

BlitzMax Forums/Brucey's Modules/Default Attr for a wxSheet cell

plash(Posted 2009) [#1]
I've tried using SetDefaultAttr, SetGridColAttr and SetAttr (with -1 indexes as well) using an attribute object that has a number renderer and editor..
Yet I can still enter non-numerical characters into the cell.

I would like to be able to set the default cell's attribute by the column in which it lies, instead of creating the attribute for each cell every single time I create a new row.


plash(Posted 2009) [#2]
Anyone?!


DavidDC(Posted 2009) [#3]
Does the number renderer/editor never work or only when you try to assign it to a whole column? It seems to work on single cells in the wxSheet sample.

I don't really have any answers (sorry), just trying to clarify the question.


Brucey(Posted 2009) [#4]
This example sets column D to number-only entry. (this should work without updating to the latest code)

SuperStrict

Framework wx.wxApp
Import wx.wxSheet
Import wx.wxFrame

New GridApp.run()


Type GridApp Extends wxApp

	Method OnInit:Int()

		Local frame:GridFrame = GridFrame(New GridFrame.Create(Null, -1, "wxSheet example"))
		
		frame.SetSize(800, 600)
		frame.show()
	
		Return True
	
	End Method

End Type


Type GridFrame Extends wxFrame

	Field grid:wxSheet
	
	Method OnInit()
	
		grid = New wxSheet.Create( Self, -1, 0, 0)
		
		grid.CreateGrid( 0, 0 )
		grid.AppendRows(20)
		grid.AppendCols(20)

		Local attr:wxSheetCellAttr = New wxSheetCellAttr.Create(True)
		
		attr.SetEditor(New wxSheetCellEditor.Create(New wxSheetCellNumberEditorRefData.Create()))
		attr.SetRenderer(New wxSheetCellRenderer.Create(New wxSheetCellNumberRendererRefData.Create()))

		grid.SetGridColAttr(3, attr)
	
	End Method


End Type

The key appears to be passing in True to wxSheetCellAttr.Create(). So, I've also updated the module to default the parameter as True rather than False.
Internally, using True, appears to initialise some internal refdata. But since the documentation is extremely lacking, I can't really give you much more information that what I see in the source...


plash(Posted 2009) [#5]
Why??!

SetGridColAttr only sets the attribute for existing rows (new rows do not have the attribute).
e.g. Try moving AppendRows(20) at the end of the OnInit method.

(Issue still unsolved...)


plash(Posted 2009) [#6]
No solution (other than doing the attribute set on new cells)?